Moved some modules and added documentation

This commit is contained in:
2026-04-06 00:15:49 +02:00
parent 1f4f8a1fbd
commit f35f040efb
29 changed files with 276 additions and 70 deletions

View File

@@ -1,193 +0,0 @@
(module menu racket/base
(require json
net/url)
(provide wv-menu
wv-menu-item
is-wv-menu?
wv-menu-set-callback!
wv-menu-set-icon!
wv-menu-set-title!
wv-menu->json
with-wv-menu-item
wv-menu-for-each
wv-menu-item-callback
wv-menu-item-id
wv-menu-id
)
(define-struct ww-menu-item*
(id [title #:mutable] [icon-url #:mutable] [callback #:mutable] [submenu #:mutable] [separator #:mutable])
#:transparent)
(define-struct ww-menu*
(id [items #:mutable])
#:transparent
)
(define (wv-menu-item-callback mi)
(ww-menu-item*-callback mi))
(define (wv-menu-item-id mi)
(ww-menu-item*-id mi))
(define (wv-menu-id m)
(ww-menu*-id m))
(define (is-wv-menu? mnu)
(if (ww-menu*? mnu)
(if (list? (ww-menu*-items mnu))
(letrec ((f (lambda (m)
(if (null? m)
#t
(if (ww-menu-item*? (car m))
(if (eq? (ww-menu-item*-submenu (car m)) #f)
(f (cdr m))
(and (is-wv-menu? (ww-menu-item*-submenu (car m)))
(f (cdr m))))
#f)
))
))
(f (ww-menu*-items mnu)))
#f)
#f))
(define (wv-menu . items)
(let ((menu-id #f))
(when (symbol? (car items))
(set! menu-id (car items))
(set! items (cdr items)))
(when (list? (car items))
(set! items (car items)))
(make-ww-menu* menu-id items)))
(define (wv-menu-item id title
#:icon-url [icon-url #f]
#:callback [callback (lambda args #t)]
#:submenu [submenu #f]
#:separator [separator #f])
(unless (symbol? id)
(error "menu-item needs an id of symbol?"))
(unless (string? title)
(error "menu-item needs a title of string?"))
(unless (or (eq? icon-url #f) (string? icon-url) (url? icon-url))
(error "menu-item's optional argument icon-file must be #f, string? or path?"))
(unless (or (eq? submenu #f) (is-wv-menu? submenu))
(error "menu-item's optional argument submenu must be #f or is-menu?"))
(unless (boolean? separator)
(error "menu-item's optional argument separator must be boolean?"))
(let ((u (if (url? icon-url) (url->string icon-url) icon-url)))
(make-ww-menu-item* id title u callback submenu separator))
)
(define (wv-menu->hash menu . for-json)
(let ((fj (if (null? for-json) #f (car for-json))))
(unless (is-wv-menu? menu)
(error "menu->hash must be called with a menu"))
(let* ((items (ww-menu*-items menu))
(r (map (λ (item)
(let ((h (make-hasheq)))
(hash-set! h 'id (format "~a" (ww-menu-item*-id item)))
(hash-set! h 'name (ww-menu-item*-title item))
(unless (eq? (ww-menu-item*-icon-url item) #f)
(hash-set! h 'icon (ww-menu-item*-icon-url item)))
(unless (eq? (ww-menu-item*-submenu item) #f)
(hash-set! h 'submenu (wv-menu->hash (ww-menu-item*-submenu item) fj)))
(unless (eq? (ww-menu-item*-separator item) #f)
(hash-set! h 'separator #t))
h
)) items))
)
(let ((h (make-hasheq)))
(hash-set! h 'menu r)
(hash-set! h 'id (if fj (format "~a" (ww-menu*-id menu)) (ww-menu*-id menu)))
h))))
(define (wv-menu-for-each menu cb)
(let ((items (ww-menu*-items menu)))
(letrec ((f (λ (items)
(if (null? items)
#t
(let ((item (car items)))
(let ((submenu (ww-menu-item*-submenu item)))
(if (eq? submenu #f)
(cb item)
(wv-menu-for-each submenu cb)))
(f (cdr items))
)
)
)
))
(f items))))
(define (wv-menu->json menu)
(let ((o (open-output-string)))
(write-json (wv-menu->hash menu #t) o)
(get-output-string o)))
(define (find-wv-menu-item menu id)
(let ((items (ww-menu*-items menu)))
(letrec ((f (λ (items)
(if (null? items)
#f
(let ((item (car items)))
(if (eq? (ww-menu-item*-id item) id)
item
(let ((submenu (ww-menu-item*-submenu item)))
(if (eq? submenu #f)
(f (cdr items))
(let ((found-item (find-wv-menu-item submenu id)))
(if (eq? found-item #f)
(f (cdr items))
found-item))
))
))
))
))
(f items))))
(define (with-wv-menu-item menu id cb)
(unless (is-wv-menu? menu)
(error "menu must be of is-menu?"))
(unless (symbol? id)
(error "id must be of symbol?"))
(let ((item (find-wv-menu-item menu id)))
(if (eq? item #f)
(error (format "cannot find id'~a in given menu" id))
(cb item)))
menu)
(define (wv-menu-set-title! menu id title)
(unless (string? title)
(error "title must be of string?"))
(with-wv-menu-item menu id
(λ (item)
(set-ww-menu-item*-title! item title))))
(define (wv-menu-set-icon! menu id icon-url)
(unless (or (eq? icon-url #f) (url? icon-url) (string? icon-url))
(error "title must be of #f, string? or path?"))
(with-wv-menu-item menu id
(λ (item)
(let ((u (if (url? icon-url) (url->string icon-url) icon-url)))
(set-ww-menu-item*-icon-url! item u)))))
(define (wv-menu-set-callback! menu id cb)
(unless (procedure? cb)
(error "callback must be of procedure?"))
(with-wv-menu-item menu id
(λ (item)
(set-ww-menu-item*-callback! item cb))))
); end of module

View File

@@ -1,724 +0,0 @@
#lang racket/base
(require racket/contract)
(provide mimetype-for-ext)
(define/contract (mimetype-for-ext ext)
(-> (or/c string? symbol?) string?)
(hash-ref mimetypes
(if (string? ext) (string->symbol ext) ext)
"application/octet-stream"))
(define mimetypes (make-hash))
(define-syntax addMimeType
(syntax-rules ()
((_ description http-mimetype extensions description2)
(for-each (λ (mimetype)
(unless (hash-has-key? mimetypes mimetype)
(hash-set! mimetypes mimetype http-mimetype)))
extensions))))
(addMimeType "3D Crossword Plugin" "application/vnd.hzn-3d-crossword" '(x3d) "IANA: 3D Crossword Plugin")
(addMimeType "3GP" "video/3gpp" '(3gp) "Wikipedia: 3GP")
(addMimeType "3GP2" "video/3gpp2" '(3g2) "Wikipedia: 3G2")
(addMimeType "3GPP MSEQ File" "application/vnd.mseq" '(mseq) "IANA: 3GPP MSEQ File")
(addMimeType "3M Post It Notes" "application/vnd.3m.post-it-notes" '(pwn) "IANA: 3M Post It Notes")
(addMimeType "3rd Generation Partnership Project - Pic Large" "application/vnd.3gpp.pic-bw-large" '(plb) "3GPP")
(addMimeType "3rd Generation Partnership Project - Pic Small" "application/vnd.3gpp.pic-bw-small" '(psb) "3GPP")
(addMimeType "3rd Generation Partnership Project - Pic Var" "application/vnd.3gpp.pic-bw-var" '(pvb) "3GPP")
(addMimeType "3rd Generation Partnership Project - Transaction Capabilities Application Part" "application/vnd.3gpp2.tcap" '(tcap) "3GPP")
(addMimeType "7-Zip" "application/x-7z-compressed" '(7z) "Wikipedia: 7-Zip")
(addMimeType "AbiWord" "application/x-abiword" '(abw) "Wikipedia: AbiWord")
(addMimeType "Ace Archive" "application/x-ace-compressed" '(ace) "Wikipedia: ACE")
(addMimeType "Active Content Compression" "application/vnd.americandynamics.acc" '(acc) "IANA: Active Content Compression")
(addMimeType "ACU Cobol" "application/vnd.acucobol" '(acu) "IANA: ACU Cobol")
(addMimeType "ACU Cobol" "application/vnd.acucorp" '(atc) "IANA: ACU Cobol")
(addMimeType "Adaptive differential pulse-code modulation" "audio/adpcm" '(adp) "Wikipedia: ADPCM")
(addMimeType "Adobe (Macropedia) Authorware - Binary File" "application/x-authorware-bin" '(aab) "Wikipedia: Authorware")
(addMimeType "Adobe (Macropedia) Authorware - Map" "application/x-authorware-map" '(aam) "Wikipedia: Authorware")
(addMimeType "Adobe (Macropedia) Authorware - Segment File" "application/x-authorware-seg" '(aas) "Wikipedia: Authorware")
(addMimeType "Adobe AIR Application" "application/vnd.adobe.air-application-installer-package+zip" '(air) "Building AIR Applications")
(addMimeType "Adobe Flash" "application/x-shockwave-flash" '(swf) "Wikipedia: Adobe Flash")
(addMimeType "Adobe Flex Project" "application/vnd.adobe.fxp" '(fxp) "IANA: Adobe Flex Project")
(addMimeType "Adobe Portable Document Format" "application/pdf" '(pdf) "Adobe PDF")
(addMimeType "Adobe PostScript Printer Description File Format" "application/vnd.cups-ppd" '(ppd) "IANA: Cups")
(addMimeType "Adobe Shockwave Player" "application/x-director" '(dir) "Wikipedia: Adobe Shockwave Player")
(addMimeType "Adobe XML Data Package" "application/vnd.adobe.xdp+xml" '(xdp) "Wikipedia: XML Data Package")
(addMimeType "Adobe XML Forms Data Format" "application/vnd.adobe.xfdf" '(xfdf) "Wikipedia: XML Portable Document Format")
(addMimeType "Advanced Audio Coding (AAC)" "audio/x-aac" '(aac) "Wikipedia: AAC")
(addMimeType "Ahead AIR Application" "application/vnd.ahead.space" '(ahead) "IANA: Ahead AIR Application")
(addMimeType "AirZip FileSECURE" "application/vnd.airzip.filesecure.azf" '(azf) "IANA: AirZip")
(addMimeType "AirZip FileSECURE" "application/vnd.airzip.filesecure.azs" '(azs) "IANA: AirZip")
(addMimeType "Amazon Kindle eBook format" "application/vnd.amazon.ebook" '(azw) "Kindle Direct Publishing")
(addMimeType "AmigaDE" "application/vnd.amiga.ami" '(ami) "IANA: Amiga")
(addMimeType "Andrew Toolkit" "application/andrew-inset" '(N/A) "IANA - Andrew Inset")
(addMimeType "Android Package Archive" "application/vnd.android.package-archive" '(apk) "Wikipedia: APK File Format")
(addMimeType "ANSER-WEB Terminal Client - Certificate Issue" "application/vnd.anser-web-certificate-issue-initiation" '(cii) "IANA: ANSWER-WEB")
(addMimeType "ANSER-WEB Terminal Client - Web Funds Transfer" "application/vnd.anser-web-funds-transfer-initiation" '(fti) "IANA: ANSWER-WEB")
(addMimeType "Antix Game Player" "application/vnd.antix.game-component" '(atx) "IANA: Antix Game Component")
(addMimeType "Apple Disk Image" "application/x-apple-diskimage" '(dmg) "Apple Disk Image")
(addMimeType "Apple Installer Package" "application/vnd.apple.installer+xml" '(mpkg) "IANA: Apple Installer")
(addMimeType "Applixware" "application/applixware" '(aw) "Vistasource")
(addMimeType "Archipelago Lesson Player" "application/vnd.hhe.lesson-player" '(les) "IANA: Archipelago Lesson Player")
(addMimeType "Archive document - Multiple Fils Embedded" "application/x-freearc" '(arc) "FreeArc")
(addMimeType "Arista Networks Software Image" "application/vnd.aristanetworks.swi" '(swi) "IANA: Arista Networks Software Image")
(addMimeType "Assembler Source File" "text/x-asm" '(s) "Wikipedia: Assembly")
(addMimeType "Atom Publishing Protocol" "application/atomcat+xml" '(atomcat) "RFC 5023")
(addMimeType "Atom Publishing Protocol Service Document" "application/atomsvc+xml" '(atomsvc) "RFC 5023")
(addMimeType "Atom Syndication Format" "application/atom+xml" '(atom xml) "RFC 4287")
(addMimeType "Attribute Certificate" "application/pkix-attr-cert" '(ac) "RFC 5877")
(addMimeType "Audio Interchange File Format" "audio/x-aiff" '(aif) "Wikipedia: Audio Interchange File Format")
(addMimeType "Audio Video Interleave (AVI)" "video/x-msvideo" '(avi) "Wikipedia: AVI")
(addMimeType "Audiograph" "application/vnd.audiograph" '(aep) "IANA: Audiograph")
(addMimeType "AutoCAD DXF" "image/vnd.dxf" '(dxf) "Wikipedia: AutoCAD DXF")
(addMimeType "Autodesk Design Web Format (DWF)" "model/vnd.dwf" '(dwf) "Wikipedia: Design Web Format")
(addMimeType "AV1 Image File" "image/avif" '(avif) "AV1 Image File Format")
(addMimeType "BAS Partitur Format" "text/plain-bas" '(par) "Phonetik BAS")
(addMimeType "Binary CPIO Archive" "application/x-bcpio" '(bcpio) "Wikipedia: cpio")
(addMimeType "Binary Data" "application/octet-stream" '(bin) "")
(addMimeType "Bitmap Image File" "image/bmp" '(bmp) "Wikipedia: BMP File Format")
(addMimeType "BitTorrent" "application/x-bittorrent" '(torrent) "Wikipedia: BitTorrent")
(addMimeType "Blackberry COD File" "application/vnd.rim.cod" '(cod) "")
(addMimeType "Blueice Research Multipass" "application/vnd.blueice.multipass" '(mpm) "IANA: Multipass")
(addMimeType "BMI Drawing Data Interchange" "application/vnd.bmi" '(bmi) "IANA: BMI")
(addMimeType "Bourne Shell Script" "application/x-sh" '(sh) "Wikipedia: Bourne Shell")
(addMimeType "BTIF" "image/prs.btif" '(btif) "IANA: BTIF")
(addMimeType "BusinessObjects" "application/vnd.businessobjects" '(rep) "IANA: BusinessObjects")
(addMimeType "Bzip Archive" "application/x-bzip" '(bz) "Wikipedia: Bzip")
(addMimeType "Bzip2 Archive" "application/x-bzip2" '(bz2) "Wikipedia: Bzip")
(addMimeType "C Shell Script" "application/x-csh" '(csh) "Wikipedia: C Shell")
(addMimeType "C Source File" "text/x-c" '(c) "Wikipedia: C Programming Language")
(addMimeType "CambridgeSoft Chem Draw" "application/vnd.chemdraw+xml" '(cdxml) "IANA: Chem Draw")
(addMimeType "Cascading Style Sheets (CSS)" "text/css" '(css) "Wikipedia: CSS")
(addMimeType "CD Audio" "application/x-cdf" '(cda) "Wikipedia: CDA File")
(addMimeType "ChemDraw eXchange file" "chemical/x-cdx" '(cdx) "ChemDraw eXchange file")
(addMimeType "Chemical Markup Language" "chemical/x-cml" '(cml) "Wikipedia: Chemical Markup Language")
(addMimeType "Chemical Style Markup Language" "chemical/x-csml" '(csml) "Wikipedia: Chemical Style Markup Language")
(addMimeType "CIM Database" "application/vnd.contact.cmsg" '(cdbcmsg) "IANA: CIM Database")
(addMimeType "Claymore Data Files" "application/vnd.claymore" '(cla) "IANA: Claymore")
(addMimeType "Clonk Game" "application/vnd.clonk.c4group" '(c4g) "IANA: Clonk")
(addMimeType "Close Captioning - Subtitle" "image/vnd.dvb.subtitle" '(sub) "Wikipedia: Closed Captioning")
(addMimeType "Cloud Data Management Interface (CDMI) - Capability" "application/cdmi-capability" '(cdmia) "RFC 6208")
(addMimeType "Cloud Data Management Interface (CDMI) - Contaimer" "application/cdmi-container" '(cdmic) "RFC 6209")
(addMimeType "Cloud Data Management Interface (CDMI) - Domain" "application/cdmi-domain" '(cdmid) "RFC 6210")
(addMimeType "Cloud Data Management Interface (CDMI) - Object" "application/cdmi-object" '(cdmio) "RFC 6211")
(addMimeType "Cloud Data Management Interface (CDMI) - Queue" "application/cdmi-queue" '(cdmiq) "RFC 6212")
(addMimeType "ClueTrust CartoMobile - Config" "application/vnd.cluetrust.cartomobile-config" '(c11amc) "IANA: CartoMobile")
(addMimeType "ClueTrust CartoMobile - Config Package" "application/vnd.cluetrust.cartomobile-config-pkg" '(c11amz) "IANA: CartoMobile")
(addMimeType "CMU Image" "image/x-cmu-raster" '(ras) "")
(addMimeType "COLLADA" "model/vnd.collada+xml" '(dae) "IANA: COLLADA")
(addMimeType "Comma-Seperated Values" "text/csv" '(csv) "Wikipedia: CSV")
(addMimeType "Compact Pro" "application/mac-compactpro" '(cpt) "Compact Pro")
(addMimeType "Compiled Wireless Markup Language (WMLC)" "application/vnd.wap.wmlc" '(wmlc) "IANA: WMLC")
(addMimeType "Computer Graphics Metafile" "image/cgm" '(cgm) "Wikipedia: Computer Graphics Metafile")
(addMimeType "CoolTalk" "x-conference/x-cooltalk" '(ice) "Wikipedia: CoolTalk")
(addMimeType "Corel Metafile Exchange (CMX)" "image/x-cmx" '(cmx) "Wikipedia: CorelDRAW")
(addMimeType "CorelXARA" "application/vnd.xara" '(xar) "IANA: CorelXARA")
(addMimeType "CosmoCaller" "application/vnd.cosmocaller" '(cmc) "IANA: CosmoCaller")
(addMimeType "CPIO Archive" "application/x-cpio" '(cpio) "Wikipedia: cpio")
(addMimeType "CrickSoftware - Clicker" "application/vnd.crick.clicker" '(clkx) "IANA: Clicker")
(addMimeType "CrickSoftware - Clicker - Keyboard" "application/vnd.crick.clicker.keyboard" '(clkk) "IANA: Clicker")
(addMimeType "CrickSoftware - Clicker - Palette" "application/vnd.crick.clicker.palette" '(clkp) "IANA: Clicker")
(addMimeType "CrickSoftware - Clicker - Template" "application/vnd.crick.clicker.template" '(clkt) "IANA: Clicker")
(addMimeType "CrickSoftware - Clicker - Wordbank" "application/vnd.crick.clicker.wordbank" '(clkw) "IANA: Clicker")
(addMimeType "Critical Tools - PERT Chart EXPERT" "application/vnd.criticaltools.wbs+xml" '(wbs) "IANA: Critical Tools")
(addMimeType "CryptoNote" "application/vnd.rig.cryptonote" '(cryptonote) "IANA: CryptoNote")
(addMimeType "Crystallographic Interchange Format" "chemical/x-cif" '(cif) "Crystallographic Interchange Format")
(addMimeType "CrystalMaker Data Format" "chemical/x-cmdf" '(cmdf) "CrystalMaker Data Format")
(addMimeType "CU-SeeMe" "application/cu-seeme" '(cu) "White Pine")
(addMimeType "CU-Writer" "application/prs.cww" '(cww) "")
(addMimeType "Curl - Applet" "text/vnd.curl" '(curl) "Curl Applet")
(addMimeType "Curl - Detached Applet" "text/vnd.curl.dcurl" '(dcurl) "Curl Detached Applet")
(addMimeType "Curl - Manifest File" "text/vnd.curl.mcurl" '(mcurl) "Curl Manifest File")
(addMimeType "Curl - Source Code" "text/vnd.curl.scurl" '(scurl) "Curl Source Code")
(addMimeType "CURL Applet" "application/vnd.curl.car" '(car) "IANA: CURL Applet")
(addMimeType "CURL Applet" "application/vnd.curl.pcurl" '(pcurl) "IANA: CURL Applet")
(addMimeType "CustomMenu" "application/vnd.yellowriver-custom-menu" '(cmp) "IANA: CustomMenu")
(addMimeType "Data Structure for the Security Suitability of Cryptographic Algorithms" "application/dssc+der" '(dssc) "RFC 5698")
(addMimeType "Data Structure for the Security Suitability of Cryptographic Algorithms" "application/dssc+xml" '(xdssc) "RFC 5698")
(addMimeType "Debian Package" "application/x-debian-package" '(deb) "Wikipedia: Debian Package")
(addMimeType "DECE Audio" "audio/vnd.dece.audio" '(uva) "IANA: Dece Audio")
(addMimeType "DECE Graphic" "image/vnd.dece.graphic" '(uvi) "IANA: DECE Graphic")
(addMimeType "DECE High Definition Video" "video/vnd.dece.hd" '(uvh) "IANA: DECE HD Video")
(addMimeType "DECE Mobile Video" "video/vnd.dece.mobile" '(uvm) "IANA: DECE Mobile Video")
(addMimeType "DECE MP4" "video/vnd.uvvu.mp4" '(uvu) "IANA: DECE MP4")
(addMimeType "DECE PD Video" "video/vnd.dece.pd" '(uvp) "IANA: DECE PD Video")
(addMimeType "DECE SD Video" "video/vnd.dece.sd" '(uvs) "IANA: DECE SD Video")
(addMimeType "DECE Video" "video/vnd.dece.video" '(uvv) "IANA: DECE Video")
(addMimeType "Device Independent File Format (DVI)" "application/x-dvi" '(dvi) "Wikipedia: DVI")
(addMimeType "Digital Siesmograph Networks - SEED Datafiles" "application/vnd.fdsn.seed" '(seed) "IANA: SEED")
(addMimeType "Digital Talking Book" "application/x-dtbook+xml" '(dtb) "Wikipedia: EPUB")
(addMimeType "Digital Talking Book - Resource File" "application/x-dtbresource+xml" '(res) "Digital Talking Book")
(addMimeType "Digital Video Broadcasting" "application/vnd.dvb.ait" '(ait) "IANA: Digital Video Broadcasting")
(addMimeType "Digital Video Broadcasting" "application/vnd.dvb.service" '(svc) "IANA: Digital Video Broadcasting")
(addMimeType "Digital Winds Music" "audio/vnd.digital-winds" '(eol) "IANA: Digital Winds")
(addMimeType "DjVu" "image/vnd.djvu" '(djvu) "Wikipedia: DjVu")
(addMimeType "Document Type Definition" "application/xml-dtd" '(dtd) "W3C DTD")
(addMimeType "Dolby Meridian Lossless Packing" "application/vnd.dolby.mlp" '(mlp) "IANA: Dolby Meridian Lossless Packing")
(addMimeType "Doom Video Game" "application/x-doom" '(wad) "Wikipedia: Doom WAD")
(addMimeType "DPGraph" "application/vnd.dpgraph" '(dpg) "IANA: DPGraph")
(addMimeType "DRA Audio" "audio/vnd.dra" '(dra) "IANA: DRA")
(addMimeType "DreamFactory" "application/vnd.dreamfactory" '(dfac) "IANA: DreamFactory")
(addMimeType "DTS Audio" "audio/vnd.dts" '(dts) "IANA: DTS")
(addMimeType "DTS High Definition Audio" "audio/vnd.dts.hd" '(dtshd) "IANA: DTS HD")
(addMimeType "DWG Drawing" "image/vnd.dwg" '(dwg) "Wikipedia: DWG")
(addMimeType "DynaGeo" "application/vnd.dynageo" '(geo) "IANA: DynaGeo")
(addMimeType "ECMAScript" "application/ecmascript" '(es) "ECMA-357")
(addMimeType "EcoWin Chart" "application/vnd.ecowin.chart" '(mag) "IANA: EcoWin Chart")
(addMimeType "EDMICS 2000" "image/vnd.fujixerox.edmics-mmr" '(mmr) "IANA: EDMICS 2000")
(addMimeType "EDMICS 2000" "image/vnd.fujixerox.edmics-rlc" '(rlc) "IANA: EDMICS 2000")
(addMimeType "Efficient XML Interchange" "application/exi" '(exi) "Efficient XML Interchange (EXI) Best Practices")
(addMimeType "EFI Proteus" "application/vnd.proteus.magazine" '(mgz) "IANA: EFI Proteus")
(addMimeType "Electronic Publication" "application/epub+zip" '(epub) "Wikipedia: EPUB")
(addMimeType "Email Message" "message/rfc822" '(eml) "RFC 2822")
(addMimeType "Enliven Viewer" "application/vnd.enliven" '(nml) "IANA: Enliven Viewer")
(addMimeType "Express by Infoseek" "application/vnd.is-xpr" '(xpr) "IANA: Express by Infoseek")
(addMimeType "eXtended Image File Format (XIFF)" "image/vnd.xiff" '(xif) "IANA: XIFF")
(addMimeType "Extensible Forms Description Language" "application/vnd.xfdl" '(xfdl) "IANA: Extensible Forms Description Language")
(addMimeType "Extensible MultiModal Annotation" "application/emma+xml" '(emma) "EMMA: Extensible MultiModal Annotation markup language")
(addMimeType "EZPix Secure Photo Album" "application/vnd.ezpix-album" '(ez2) "IANA: EZPix Secure Photo Album")
(addMimeType "EZPix Secure Photo Album" "application/vnd.ezpix-package" '(ez3) "IANA: EZPix Secure Photo Album")
(addMimeType "FAST Search & Transfer ASA" "image/vnd.fst" '(fst) "IANA: FAST Search & Transfer ASA")
(addMimeType "FAST Search & Transfer ASA" "video/vnd.fvt" '(fvt) "IANA: FVT")
(addMimeType "FastBid Sheet" "image/vnd.fastbidsheet" '(fbs) "IANA: FastBid Sheet")
(addMimeType "FCS Express Layout Link" "application/vnd.denovo.fcselayout-link" '(fe_launch) "IANA: FCS Express Layout Link")
(addMimeType "Flash Video" "video/x-f4v" '(f4v) "Wikipedia: Flash Video")
(addMimeType "Flash Video" "video/x-flv" '(flv) "Wikipedia: Flash Video")
(addMimeType "FlashPix" "image/vnd.fpx" '(fpx) "IANA: FPX")
(addMimeType "FlashPix" "image/vnd.net-fpx" '(npx) "IANA: FPX")
(addMimeType "FLEXSTOR" "text/vnd.fmi.flexstor" '(flx) "IANA: FLEXSTOR")
(addMimeType "FLI/FLC Animation Format" "video/x-fli" '(fli) "FLI/FLC Animation Format")
(addMimeType "FluxTime Clip" "application/vnd.fluxtime.clip" '(ftc) "IANA: FluxTime Clip")
(addMimeType "Forms Data Format" "application/vnd.fdf" '(fdf) "IANA: Forms Data Format")
(addMimeType "Fortran Source File" "text/x-fortran" '(f) "Wikipedia: Fortran")
(addMimeType "FrameMaker Interchange Format" "application/vnd.mif" '(mif) "IANA: FrameMaker Interchange Format")
(addMimeType "FrameMaker Normal Format" "application/vnd.framemaker" '(fm) "IANA: FrameMaker")
(addMimeType "FreeHand MX" "image/x-freehand" '(fh) "Wikipedia: Macromedia Freehand")
(addMimeType "Friendly Software Corporation" "application/vnd.fsc.weblaunch" '(fsc) "IANA: Friendly Software Corporation")
(addMimeType "Frogans Player" "application/vnd.frogans.fnc" '(fnc) "IANA: Frogans Player")
(addMimeType "Frogans Player" "application/vnd.frogans.ltf" '(ltf) "IANA: Frogans Player")
(addMimeType "Fujitsu - Xerox 2D CAD Data" "application/vnd.fujixerox.ddd" '(ddd) "IANA: Fujitsu DDD")
(addMimeType "Fujitsu - Xerox DocuWorks" "application/vnd.fujixerox.docuworks" '(xdw) "IANA: Docuworks")
(addMimeType "Fujitsu - Xerox DocuWorks Binder" "application/vnd.fujixerox.docuworks.binder" '(xbd) "IANA: Docuworks Binder")
(addMimeType "Fujitsu Oasys" "application/vnd.fujitsu.oasys" '(oas) "IANA: Fujitsu Oasys")
(addMimeType "Fujitsu Oasys" "application/vnd.fujitsu.oasys2" '(oa2) "IANA: Fujitsu Oasys")
(addMimeType "Fujitsu Oasys" "application/vnd.fujitsu.oasys3" '(oa3) "IANA: Fujitsu Oasys")
(addMimeType "Fujitsu Oasys" "application/vnd.fujitsu.oasysgp" '(fg5) "IANA: Fujitsu Oasys")
(addMimeType "Fujitsu Oasys" "application/vnd.fujitsu.oasysprs" '(bh2) "IANA: Fujitsu Oasys")
(addMimeType "FutureSplash Animator" "application/x-futuresplash" '(spl) "Wikipedia: FutureSplash Animator")
(addMimeType "FuzzySheet" "application/vnd.fuzzysheet" '(fzs) "IANA: FuzySheet")
(addMimeType "G3 Fax Image" "image/g3fax" '(g3) "Wikipedia: G3 Fax Image")
(addMimeType "GameMaker ActiveX" "application/vnd.gmx" '(gmx) "IANA: GameMaker ActiveX")
(addMimeType "Gen-Trix Studio" "model/vnd.gtw" '(gtw) "IANA: GTW")
(addMimeType "Genomatix Tuxedo Framework" "application/vnd.genomatix.tuxedo" '(txd) "IANA: Genomatix Tuxedo Framework")
(addMimeType "GeoGebra" "application/vnd.geogebra.file" '(ggb) "IANA: GeoGebra")
(addMimeType "GeoGebra" "application/vnd.geogebra.tool" '(ggt) "IANA: GeoGebra")
(addMimeType "Geometric Description Language (GDL)" "model/vnd.gdl" '(gdl) "IANA: GDL")
(addMimeType "GeoMetry Explorer" "application/vnd.geometry-explorer" '(gex) "IANA: GeoMetry Explorer")
(addMimeType "GEONExT and JSXGraph" "application/vnd.geonext" '(gxt) "IANA: GEONExT and JSXGraph")
(addMimeType "GeoplanW" "application/vnd.geoplan" '(g2w) "IANA: GeoplanW")
(addMimeType "GeospacW" "application/vnd.geospace" '(g3w) "IANA: GeospacW")
(addMimeType "Ghostscript Font" "application/x-font-ghostscript" '(gsf) "Wikipedia: Ghostscript")
(addMimeType "Glyph Bitmap Distribution Format" "application/x-font-bdf" '(bdf) "Wikipedia: Glyph Bitmap Distribution Format")
(addMimeType "GNU Tar Files" "application/x-gtar" '(gtar) "GNU Tar")
(addMimeType "GNU Texinfo Document" "application/x-texinfo" '(texinfo) "Wikipedia: Texinfo")
(addMimeType "Gnumeric" "application/x-gnumeric" '(gnumeric) "Wikipedia: Gnumeric")
(addMimeType "Google Earth - KML" "application/vnd.google-earth.kml+xml" '(kml) "IANA: Google Earth")
(addMimeType "Google Earth - Zipped KML" "application/vnd.google-earth.kmz" '(kmz) "IANA: Google Earth")
(addMimeType "GPS eXchange Format" "application/gpx+xml" '(gpx) "GPS eXchange Format")
(addMimeType "GrafEq" "application/vnd.grafeq" '(gqf) "IANA: GrafEq")
(addMimeType "Graphics Interchange Format" "image/gif" '(gif) "Wikipedia: Graphics Interchange Format")
(addMimeType "Graphviz" "text/vnd.graphviz" '(gv) "IANA: Graphviz")
(addMimeType "Groove - Account" "application/vnd.groove-account" '(gac) "IANA: Groove")
(addMimeType "Groove - Help" "application/vnd.groove-help" '(ghf) "IANA: Groove")
(addMimeType "Groove - Identity Message" "application/vnd.groove-identity-message" '(gim) "IANA: Groove")
(addMimeType "Groove - Injector" "application/vnd.groove-injector" '(grv) "IANA: Groove")
(addMimeType "Groove - Tool Message" "application/vnd.groove-tool-message" '(gtm) "IANA: Groove")
(addMimeType "Groove - Tool Template" "application/vnd.groove-tool-template" '(tpl) "IANA: Groove")
(addMimeType "Groove - Vcard" "application/vnd.groove-vcard" '(vcg) "IANA: Groove")
(addMimeType "GZip" "application/gzip" '(gz) "Wikipedia: GZip")
(addMimeType "H.261" "video/h261" '(h261) "Wikipedia: H.261")
(addMimeType "H.263" "video/h263" '(h263) "Wikipedia: H.263")
(addMimeType "H.264" "video/h264" '(h264) "Wikipedia: H.264")
(addMimeType "Hewlett Packard Instant Delivery" "application/vnd.hp-hpid" '(hpid) "IANA: Hewlett Packard Instant Delivery")
(addMimeType "Hewlett-Packard's WebPrintSmart" "application/vnd.hp-hps" '(hps) "IANA: Hewlett-Packard's WebPrintSmart")
(addMimeType "Hierarchical Data Format" "application/x-hdf" '(hdf) "Wikipedia: Hierarchical Data Format")
(addMimeType "Hit'n'Mix" "audio/vnd.rip" '(rip) "IANA: Hit'n'Mix")
(addMimeType "Homebanking Computer Interface (HBCI)" "application/vnd.hbci" '(hbci) "IANA: HBCI")
(addMimeType "HP Indigo Digital Press - Job Layout Languate" "application/vnd.hp-jlyt" '(jlt) "IANA: HP Job Layout Language")
(addMimeType "HP Printer Command Language" "application/vnd.hp-pcl" '(pcl) "IANA: HP Printer Command Language")
(addMimeType "HP-GL/2 and HP RTL" "application/vnd.hp-hpgl" '(hpgl) "IANA: HP-GL/2 and HP RTL")
(addMimeType "HV Script" "application/vnd.yamaha.hv-script" '(hvs) "IANA: HV Script")
(addMimeType "HV Voice Dictionary" "application/vnd.yamaha.hv-dic" '(hvd) "IANA: HV Voice Dictionary")
(addMimeType "HV Voice Parameter" "application/vnd.yamaha.hv-voice" '(hvp) "IANA: HV Voice Parameter")
(addMimeType "Hydrostatix Master Suite" "application/vnd.hydrostatix.sof-data" '(sfd-hdstx) "IANA: Hydrostatix Master Suite")
(addMimeType "Hyperstudio" "application/hyperstudio" '(stk) "IANA - Hyperstudio")
(addMimeType "Hypertext Application Language" "application/vnd.hal+xml" '(hal) "IANA: HAL")
(addMimeType "HyperText Markup Language (HTML)" "text/html" '(html) "Wikipedia: HTML")
(addMimeType "IBM DB2 Rights Manager" "application/vnd.ibm.rights-management" '(irm) "IANA: IBM DB2 Rights Manager")
(addMimeType "IBM Electronic Media Management System - Secure Container" "application/vnd.ibm.secure-container" '(sc) "IANA: EMMS")
(addMimeType "iCalendar" "text/calendar" '(ics) "Wikipedia: iCalendar")
(addMimeType "ICC profile" "application/vnd.iccprofile" '(icc) "IANA: ICC profile")
(addMimeType "Icon Image" "image/x-icon" '(ico) "Wikipedia: ICO File Format")
(addMimeType "igLoader" "application/vnd.igloader" '(igl) "IANA: igLoader")
(addMimeType "Image Exchange Format" "image/ief" '(ief) "RFC 1314")
(addMimeType "ImmerVision PURE Players" "application/vnd.immervision-ivp" '(ivp) "IANA: ImmerVision PURE Players")
(addMimeType "ImmerVision PURE Players" "application/vnd.immervision-ivu" '(ivu) "IANA: ImmerVision PURE Players")
(addMimeType "IMS Networks" "application/reginfo+xml" '(rif) "")
(addMimeType "In3D - 3DML" "text/vnd.in3d.3dml" '(3dml) "IANA: In3D")
(addMimeType "In3D - 3DML" "text/vnd.in3d.spot" '(spot) "IANA: In3D")
(addMimeType "Initial Graphics Exchange Specification (IGES)" "model/iges" '(igs) "Wikipedia: IGES")
(addMimeType "Interactive Geometry Software" "application/vnd.intergeo" '(i2g) "IANA: Interactive Geometry Software")
(addMimeType "Interactive Geometry Software Cinderella" "application/vnd.cinderella" '(cdy) "IANA: Cinderella")
(addMimeType "Intercon FormNet" "application/vnd.intercon.formnet" '(xpw) "IANA: Intercon FormNet")
(addMimeType "International Society for Advancement of Cytometry" "application/vnd.isac.fcs" '(fcs) "IANA: International Society for Advancement of Cytometry")
(addMimeType "Internet Protocol Flow Information Export" "application/ipfix" '(ipfix) "RFC 3917")
(addMimeType "Internet Public Key Infrastructure - Certificate" "application/pkix-cert" '(cer) "RFC 2585")
(addMimeType "Internet Public Key Infrastructure - Certificate Management Protocole" "application/pkixcmp" '(pki) "RFC 2585")
(addMimeType "Internet Public Key Infrastructure - Certificate Revocation Lists" "application/pkix-crl" '(crl) "RFC 2585")
(addMimeType "Internet Public Key Infrastructure - Certification Path" "application/pkix-pkipath" '(pkipath) "RFC 2585")
(addMimeType "IOCOM Visimeet" "application/vnd.insors.igm" '(igm) "IANA: IOCOM Visimeet")
(addMimeType "IP Unplugged Roaming Client" "application/vnd.ipunplugged.rcprofile" '(rcprofile) "IANA: IP Unplugged Roaming Client")
(addMimeType "iRepository / Lucidoc Editor" "application/vnd.irepository.package+xml" '(irp) "IANA: iRepository / Lucidoc Editor")
(addMimeType "J2ME App Descriptor" "text/vnd.sun.j2me.app-descriptor" '(jad) "IANA: J2ME App Descriptor")
(addMimeType "Java Archive" "application/java-archive" '(jar) "Wikipedia: JAR file format")
(addMimeType "Java Bytecode File" "application/java-vm" '(class) "Wikipedia: Java Bytecode")
(addMimeType "Java Network Launching Protocol" "application/x-java-jnlp-file" '(jnlp) "Wikipedia: Java Web Start")
(addMimeType "Java Serialized Object" "application/java-serialized-object" '(ser) "Java Serialization API")
(addMimeType "Java Source File" "text/x-java-source,java" '(java) "Wikipedia: Java")
(addMimeType "JavaScript" "application/javascript" '(js) "JavaScript")
(addMimeType "JavaScript Module" "text/javascript" '(mjs) "Wikipedia: Javascript")
(addMimeType "JavaScript Module" "text/javascript" '(mjs) "ECMAScript modules")
(addMimeType "JavaScript Object Notation (JSON)" "application/json" '(json) "Wikipedia: JSON")
(addMimeType "Joda Archive" "application/vnd.joost.joda-archive" '(joda) "IANA: Joda Archive")
(addMimeType "JPEG Image" "image/jpeg" '(jpeg jpg) "RFC 1314")
(addMimeType "JPEG 2000 Compound Image File Format" "video/jpm" '(jpm) "IANA: JPM")
(addMimeType "JPEG Image (Citrix client)" "image/x-citrix-jpeg" '(jpeg jpg) "RFC 1314")
(addMimeType "JPEG Image (Progressive)" "image/pjpeg" '(pjpeg) "JPEG image compression FAQ")
(addMimeType "JPGVideo" "video/jpeg" '(jpgv) "RFC 3555")
(addMimeType "JSON - Linked Data" "application/ld+json" '(jsonld) "Wikipedia: JSON-LD")
(addMimeType "Kahootz" "application/vnd.kahootz" '(ktz) "IANA: Kahootz")
(addMimeType "Karaoke on Chipnuts Chipsets" "application/vnd.chipnuts.karaoke-mmd" '(mmd) "IANA: Chipnuts Karaoke")
(addMimeType "KDE KOffice Office Suite - Karbon" "application/vnd.kde.karbon" '(karbon) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - KChart" "application/vnd.kde.kchart" '(chrt) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kformula" "application/vnd.kde.kformula" '(kfo) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kivio" "application/vnd.kde.kivio" '(flw) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kontour" "application/vnd.kde.kontour" '(kon) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kpresenter" "application/vnd.kde.kpresenter" '(kpr) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kspread" "application/vnd.kde.kspread" '(ksp) "IANA: KDE KOffice Office Suite")
(addMimeType "KDE KOffice Office Suite - Kword" "application/vnd.kde.kword" '(kwd) "IANA: KDE KOffice Office Suite")
(addMimeType "Kenamea App" "application/vnd.kenameaapp" '(htke) "IANA: Kenamea App")
(addMimeType "Kidspiration" "application/vnd.kidspiration" '(kia) "IANA: Kidspiration")
(addMimeType "Kinar Applications" "application/vnd.kinar" '(kne) "IANA: Kina Applications")
(addMimeType "Kodak Storyshare" "application/vnd.kodak-descriptor" '(sse) "IANA: Kodak Storyshare")
(addMimeType "Laser App Enterprise" "application/vnd.las.las+xml" '(lasxml) "IANA: Laser App Enterprise")
(addMimeType "LaTeX" "application/x-latex" '(latex) "Wikipedia: LaTeX")
(addMimeType "Life Balance - Desktop Edition" "application/vnd.llamagraphics.life-balance.desktop" '(lbd) "IANA: Life Balance")
(addMimeType "Life Balance - Exchange Format" "application/vnd.llamagraphics.life-balance.exchange+xml" '(lbe) "IANA: Life Balance")
(addMimeType "Lightspeed Audio Lab" "application/vnd.jam" '(jam) "IANA: Lightspeed Audio Lab")
(addMimeType "Lotus 1-2-3" "application/vnd.lotus-1-2-3" '(123) "IANA: Lotus 1-2-3")
(addMimeType "Lotus Approach" "application/vnd.lotus-approach" '(apr) "IANA: Lotus Approach")
(addMimeType "Lotus Freelance" "application/vnd.lotus-freelance" '(pre) "IANA: Lotus Freelance")
(addMimeType "Lotus Notes" "application/vnd.lotus-notes" '(nsf) "IANA: Lotus Notes")
(addMimeType "Lotus Organizer" "application/vnd.lotus-organizer" '(org) "IANA: Lotus Organizer")
(addMimeType "Lotus Screencam" "application/vnd.lotus-screencam" '(scm) "IANA: Lotus Screencam")
(addMimeType "Lotus Wordpro" "application/vnd.lotus-wordpro" '(lwp) "IANA: Lotus Wordpro")
(addMimeType "Lucent Voice" "audio/vnd.lucent.voice" '(lvp) "IANA: Lucent Voice")
(addMimeType "M3U (Multimedia Playlist)" "audio/x-mpegurl" '(m3u) "Wikipedia: M3U")
(addMimeType "M4v" "video/x-m4v" '(m4v) "Wikipedia: M4v")
(addMimeType "Macintosh BinHex 4.0" "application/mac-binhex40" '(hqx) "MacMIME")
(addMimeType "MacPorts Port System" "application/vnd.macports.portpkg" '(portpkg) "IANA: MacPorts Port System")
(addMimeType "MapGuide DBXML" "application/vnd.osgeo.mapguide.package" '(mgp) "IANA: MapGuide DBXML")
(addMimeType "MARC Formats" "application/marc" '(mrc) "RFC 2220")
(addMimeType "MARC21 XML Schema" "application/marcxml+xml" '(mrcx) "RFC 6207")
(addMimeType "Material Exchange Format" "application/mxf" '(mxf) "RFC 4539")
(addMimeType "Mathematica Notebook Player" "application/vnd.wolfram.player" '(nbp) "IANA: Mathematica Notebook Player")
(addMimeType "Mathematica Notebooks" "application/mathematica" '(ma) "IANA - Mathematica")
(addMimeType "Mathematical Markup Language" "application/mathml+xml" '(mathml) "W3C Math Home")
(addMimeType "Mbox database files" "application/mbox" '(mbox) "RFC 4155")
(addMimeType "MedCalc" "application/vnd.medcalcdata" '(mc1) "IANA: MedCalc")
(addMimeType "Media Server Control Markup Language" "application/mediaservercontrol+xml" '(mscml) "RFC 5022")
(addMimeType "MediaRemote" "application/vnd.mediastation.cdkey" '(cdkey) "IANA: MediaRemote")
(addMimeType "Medical Waveform Encoding Format" "application/vnd.mfer" '(mwf) "IANA: Medical Waveform Encoding Format")
(addMimeType "Melody Format for Mobile Platform" "application/vnd.mfmp" '(mfm) "IANA: Melody Format for Mobile Platform")
(addMimeType "Mesh Data Type" "model/mesh" '(msh) "RFC 2077")
(addMimeType "Metadata Authority Description Schema" "application/mads+xml" '(mads) "RFC 6207")
(addMimeType "Metadata Encoding and Transmission Standard" "application/mets+xml" '(mets) "RFC 6207")
(addMimeType "Metadata Object Description Schema" "application/mods+xml" '(mods) "RFC 6207")
(addMimeType "Metalink" "application/metalink4+xml" '(meta4) "Wikipedia: Metalink")
(addMimeType "Micro CADAM Helix D&D" "application/vnd.mcd" '(mcd) "IANA: Micro CADAM Helix D&D")
(addMimeType "Micrografx" "application/vnd.micrografx.flo" '(flo) "IANA: Micrografx")
(addMimeType "Micrografx iGrafx Professional" "application/vnd.micrografx.igx" '(igx) "IANA: Micrografx")
(addMimeType "MICROSEC e-Szign?" "application/vnd.eszigno3+xml" '(es3) "IANA: MICROSEC e-Szign?")
(addMimeType "Microsoft Access" "application/x-msaccess" '(mdb) "Wikipedia: Microsoft Access")
(addMimeType "Microsoft Advanced Systems Format (ASF)" "video/x-ms-asf" '(asf) "Wikipedia: Advanced Systems Format (ASF)")
(addMimeType "Microsoft Application" "application/x-msdownload" '(exe) "Wikipedia: EXE")
(addMimeType "Microsoft Artgalry" "application/vnd.ms-artgalry" '(cil) "IANA: MS Artgalry")
(addMimeType "Microsoft Cabinet File" "application/vnd.ms-cab-compressed" '(cab) "IANA: MS Cabinet File")
(addMimeType "Microsoft Class Server" "application/vnd.ms-ims" '(ims) "IANA: MS Class Server")
(addMimeType "Microsoft ClickOnce" "application/x-ms-application" '(application) "Wikipedia: ClickOnce")
(addMimeType "Microsoft Clipboard Clip" "application/x-msclip" '(clp) "Wikipedia: Clipboard")
(addMimeType "Microsoft Document Imaging Format" "image/vnd.ms-modi" '(mdi) "Wikipedia: Microsoft Document Image Format")
(addMimeType "Microsoft Embedded OpenType" "application/vnd.ms-fontobject" '(eot) "IANA: MS Embedded OpenType")
(addMimeType "Microsoft Excel" "application/vnd.ms-excel" '(xls) "IANA: MS Excel")
(addMimeType "Microsoft Excel - Add-In File" "application/vnd.ms-excel.addin.macroenabled.12" '(xlam) "IANA: MS Excel")
(addMimeType "Microsoft Excel - Binary Workbook" "application/vnd.ms-excel.sheet.binary.macroenabled.12" '(xlsb) "IANA: MS Excel")
(addMimeType "Microsoft Excel - Macro-Enabled Template File" "application/vnd.ms-excel.template.macroenabled.12" '(xltm) "IANA: MS Excel")
(addMimeType "Microsoft Excel - Macro-Enabled Workbook" "application/vnd.ms-excel.sheet.macroenabled.12" '(xlsm) "IANA: MS Excel")
(addMimeType "Microsoft Html Help File" "application/vnd.ms-htmlhelp" '(chm) "IANA:MS Html Help File")
(addMimeType "Microsoft Information Card" "application/x-mscardfile" '(crd) "Wikipedia: Information Card")
(addMimeType "Microsoft Learning Resource Module" "application/vnd.ms-lrm" '(lrm) "IANA: MS Learning Resource Module")
(addMimeType "Microsoft MediaView" "application/x-msmediaview" '(mvb) "Windows Help")
(addMimeType "Microsoft Money" "application/x-msmoney" '(mny) "Wikipedia: Microsoft Money")
(addMimeType "Microsoft Office - OOXML - Presentation" "application/vnd.openxmlformats-officedocument.presentationml.presentation" '(pptx) "IANA: OOXML - Presentation")
(addMimeType "Microsoft Office - OOXML - Presentation (Slide)" "application/vnd.openxmlformats-officedocument.presentationml.slide" '(sldx) "IANA: OOXML - Presentation")
(addMimeType "Microsoft Office - OOXML - Presentation (Slideshow)" "application/vnd.openxmlformats-officedocument.presentationml.slideshow" '(ppsx) "IANA: OOXML - Presentation")
(addMimeType "Microsoft Office - OOXML - Presentation Template" "application/vnd.openxmlformats-officedocument.presentationml.template" '(potx) "IANA: OOXML - Presentation Template")
(addMimeType "Microsoft Office - OOXML - Spreadsheet" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" '(xlsx) "IANA: OOXML - Spreadsheet")
(addMimeType "Microsoft Office - OOXML - Spreadsheet Template" "application/vnd.openxmlformats-officedocument.spreadsheetml.template" '(xltx) "IANA: OOXML - Spreadsheet Template")
(addMimeType "Microsoft Office - OOXML - Word Document" "application/vnd.openxmlformats-officedocument.wordprocessingml.document" '(docx) "IANA: OOXML - Word Document")
(addMimeType "Microsoft Office - OOXML - Word Document Template" "application/vnd.openxmlformats-officedocument.wordprocessingml.template" '(dotx) "IANA: OOXML - Word Document Template")
(addMimeType "Microsoft Office Binder" "application/x-msbinder" '(obd) "Wikipedia: Microsoft Shared Tools")
(addMimeType "Microsoft Office System Release Theme" "application/vnd.ms-officetheme" '(thmx) "IANA: MS Office System Release Theme")
(addMimeType "Microsoft OneNote" "application/onenote" '(onetoc) "MS OneNote 2010")
(addMimeType "Microsoft PlayReady Ecosystem" "audio/vnd.ms-playready.media.pya" '(pya) "IANA: Microsoft PlayReady Ecosystem")
(addMimeType "Microsoft PlayReady Ecosystem Video" "video/vnd.ms-playready.media.pyv" '(pyv) "IANA: Microsoft PlayReady Ecosystem")
(addMimeType "Microsoft PowerPoint" "application/vnd.ms-powerpoint" '(ppt) "IANA: MS PowerPoint")
(addMimeType "Microsoft PowerPoint - Add-in file" "application/vnd.ms-powerpoint.addin.macroenabled.12" '(ppam) "IANA: MS PowerPoint")
(addMimeType "Microsoft PowerPoint - Macro-Enabled Open XML Slide" "application/vnd.ms-powerpoint.slide.macroenabled.12" '(sldm) "IANA: MS PowerPoint")
(addMimeType "Microsoft PowerPoint - Macro-Enabled Presentation File" "application/vnd.ms-powerpoint.presentation.macroenabled.12" '(pptm) "IANA: MS PowerPoint")
(addMimeType "Microsoft PowerPoint - Macro-Enabled Slide Show File" "application/vnd.ms-powerpoint.slideshow.macroenabled.12" '(ppsm) "IANA: MS PowerPoint")
(addMimeType "Microsoft PowerPoint - Macro-Enabled Template File" "application/vnd.ms-powerpoint.template.macroenabled.12" '(potm) "IANA: MS PowerPoint")
(addMimeType "Microsoft Project" "application/vnd.ms-project" '(mpp) "IANA: MS PowerPoint")
(addMimeType "Microsoft Publisher" "application/x-mspublisher" '(pub) "Wikipedia: Microsoft Publisher")
(addMimeType "Microsoft Schedule+" "application/x-msschedule" '(scd) "Wikipedia: Microsoft Schedule Plus")
(addMimeType "Microsoft Silverlight" "application/x-silverlight-app" '(xap) "Wikipedia: Silverlight")
(addMimeType "Microsoft Trust UI Provider - Certificate Trust Link" "application/vnd.ms-pki.stl" '(stl) "IANA: MS Trust UI Provider")
(addMimeType "Microsoft Trust UI Provider - Security Catalog" "application/vnd.ms-pki.seccat" '(cat) "IANA: MS Trust UI Provider")
(addMimeType "Microsoft Visio" "application/vnd.visio" '(vsd) "IANA: Visio")
(addMimeType "Microsoft Visio 2013" "application/vnd.visio2013" '(vsdx) "IANA: Visio")
(addMimeType "Microsoft Windows Media" "video/x-ms-wm" '(wm) "Wikipedia: Advanced Systems Format (ASF)")
(addMimeType "Microsoft Windows Media Audio" "audio/x-ms-wma" '(wma) "Wikipedia: Windows Media Audio")
(addMimeType "Microsoft Windows Media Audio Redirector" "audio/x-ms-wax" '(wax) "Windows Media Metafiles")
(addMimeType "Microsoft Windows Media Audio/Video Playlist" "video/x-ms-wmx" '(wmx) "Wikipedia: Advanced Systems Format (ASF)")
(addMimeType "Microsoft Windows Media Player Download Package" "application/x-ms-wmd" '(wmd) "Wikipedia: Windows Media Player")
(addMimeType "Microsoft Windows Media Player Playlist" "application/vnd.ms-wpl" '(wpl) "IANA: MS Windows Media Player Playlist")
(addMimeType "Microsoft Windows Media Player Skin Package" "application/x-ms-wmz" '(wmz) "Wikipedia: Windows Media Player")
(addMimeType "Microsoft Windows Media Video" "video/x-ms-wmv" '(wmv) "Wikipedia: Advanced Systems Format (ASF)")
(addMimeType "Microsoft Windows Media Video Playlist" "video/x-ms-wvx" '(wvx) "Wikipedia: Advanced Systems Format (ASF)")
(addMimeType "Microsoft Windows Metafile" "application/x-msmetafile" '(wmf) "Wikipedia: Windows Metafile")
(addMimeType "Microsoft Windows Terminal Services" "application/x-msterminal" '(trm) "Wikipedia: Terminal Server")
(addMimeType "Microsoft Word" "application/msword" '(doc) "Wikipedia: Microsoft Word")
(addMimeType "Microsoft Word - Macro-Enabled Document" "application/vnd.ms-word.document.macroenabled.12" '(docm) "IANA: MS Word")
(addMimeType "Microsoft Word - Macro-Enabled Template" "application/vnd.ms-word.template.macroenabled.12" '(dotm) "IANA: MS Word")
(addMimeType "Microsoft Wordpad" "application/x-mswrite" '(wri) "Wikipedia: Wordpad")
(addMimeType "Microsoft Works" "application/vnd.ms-works" '(wps) "IANA: MS Works")
(addMimeType "Microsoft XAML Browser Application" "application/x-ms-xbap" '(xbap) "Wikipedia: XAML Browser")
(addMimeType "Microsoft XML Paper Specification" "application/vnd.ms-xpsdocument" '(xps) "IANA: MS XML Paper Specification")
(addMimeType "MIDI" "audio/midi" '(midi) "Wikipedia: MIDI")
(addMimeType "MIDI - Musical Instrument Digital Interface" "audio/midi" '(mid) "Wikipedia: MIDI")
(addMimeType "MiniPay" "application/vnd.ibm.minipay" '(mpy) "IANA: MiniPay")
(addMimeType "MO:DCA-P" "application/vnd.ibm.modcap" '(afp) "IANA: MO:DCA-P")
(addMimeType "Mobile Information Device Profile" "application/vnd.jcp.javame.midlet-rms" '(rms) "IANA: Mobile Information Device Profile")
(addMimeType "MobileTV" "application/vnd.tmobile-livetv" '(tmo) "IANA: MobileTV")
(addMimeType "Mobipocket" "application/x-mobipocket-ebook" '(prc) "Wikipedia: Mobipocket")
(addMimeType "Mobius Management Systems - Basket file" "application/vnd.mobius.mbk" '(mbk) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - Distribution Database" "application/vnd.mobius.dis" '(dis) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - Policy Definition Language File" "application/vnd.mobius.plc" '(plc) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - Query File" "application/vnd.mobius.mqy" '(mqy) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - Script Language" "application/vnd.mobius.msl" '(msl) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - Topic Index File" "application/vnd.mobius.txf" '(txf) "IANA: Mobius Management Systems")
(addMimeType "Mobius Management Systems - UniversalArchive" "application/vnd.mobius.daf" '(daf) "IANA: Mobius Management Systems")
(addMimeType "mod_fly / fly.cgi" "text/vnd.fly" '(fly) "IANA: Fly")
(addMimeType "Mophun Certificate" "application/vnd.mophun.certificate" '(mpc) "IANA: Mophun Certificate")
(addMimeType "Mophun VM" "application/vnd.mophun.application" '(mpn) "IANA: Mophun VM")
(addMimeType "Motion JPEG 2000" "video/mj2" '(mj2) "IANA: MJ2")
(addMimeType "MPEG Audio" "audio/mpeg" '(mpga) "Wikipedia: MPGA")
(addMimeType "MPEG Transport Stream" "video/mp2t" '(ts) "Wikipedia: MPEG Transport Stream")
(addMimeType "MPEG Url" "video/vnd.mpegurl" '(mxu) "IANA: MPEG Url")
(addMimeType "MPEG Video" "video/mpeg" '(mpeg) "Wikipedia: MPEG")
(addMimeType "MPEG-21" "application/mp21" '(m21) "Wikipedia: MPEG-21")
(addMimeType "MPEG-4 Audio" "audio/mp4" '(mp4a) "Wikipedia: MP4A")
(addMimeType "MPEG-4 Video" "video/mp4" '(mp4) "Wikipedia: MP4")
(addMimeType "MPEG4" "application/mp4" '(mp4) "RFC 4337")
(addMimeType "Multimedia Playlist Unicode" "application/vnd.apple.mpegurl" '(m3u8) "Wikipedia: M3U")
(addMimeType "MUsical Score Interpreted Code Invented for the ASCII designation of Notation" "application/vnd.musician" '(mus) "IANA: MUSICIAN")
(addMimeType "Muvee Automatic Video Editing" "application/vnd.muvee.style" '(msty) "IANA: Muvee")
(addMimeType "MXML" "application/xv+xml" '(mxml) "Wikipedia: MXML")
(addMimeType "N-Gage Game Data" "application/vnd.nokia.n-gage.data" '(ngdat) "IANA: N-Gage Game Data")
(addMimeType "N-Gage Game Installer" "application/vnd.nokia.n-gage.symbian.install" '(n-gage) "IANA: N-Gage Game Installer")
(addMimeType "Navigation Control file for XML (for ePub)" "application/x-dtbncx+xml" '(ncx) "Wikipedia: EPUB")
(addMimeType "Network Common Data Form (NetCDF)" "application/x-netcdf" '(nc) "Wikipedia: NetCDF")
(addMimeType "neuroLanguage" "application/vnd.neurolanguage.nlu" '(nlu) "IANA: neuroLanguage")
(addMimeType "New Moon Liftoff/DNA" "application/vnd.dna" '(dna) "IANA: New Moon Liftoff/DNA")
(addMimeType "NobleNet Directory" "application/vnd.noblenet-directory" '(nnd) "IANA: NobleNet Directory")
(addMimeType "NobleNet Sealer" "application/vnd.noblenet-sealer" '(nns) "IANA: NobleNet Sealer")
(addMimeType "NobleNet Web" "application/vnd.noblenet-web" '(nnw) "IANA: NobleNet Web")
(addMimeType "Nokia Radio Application - Preset" "application/vnd.nokia.radio-preset" '(rpst) "IANA: Nokia Radio Application")
(addMimeType "Nokia Radio Application - Preset" "application/vnd.nokia.radio-presets" '(rpss) "IANA: Nokia Radio Application")
(addMimeType "Notation3" "text/n3" '(n3) "Wikipedia: Notation3")
(addMimeType "Novadigm's RADIA and EDM products" "application/vnd.novadigm.edm" '(edm) "IANA: Novadigm's RADIA and EDM products")
(addMimeType "Novadigm's RADIA and EDM products" "application/vnd.novadigm.edx" '(edx) "IANA: Novadigm's RADIA and EDM products")
(addMimeType "Novadigm's RADIA and EDM products" "application/vnd.novadigm.ext" '(ext) "IANA: Novadigm's RADIA and EDM products")
(addMimeType "NpGraphIt" "application/vnd.flographit" '(gph) "IANA: FloGraphIt")
(addMimeType "Nuera ECELP 4800" "audio/vnd.nuera.ecelp4800" '(ecelp4800) "IANA: ECELP 4800")
(addMimeType "Nuera ECELP 7470" "audio/vnd.nuera.ecelp7470" '(ecelp7470) "IANA: ECELP 7470")
(addMimeType "Nuera ECELP 9600" "audio/vnd.nuera.ecelp9600" '(ecelp9600) "IANA: ECELP 9600")
(addMimeType "Office Document Architecture" "application/oda" '(oda) "RFC 2161")
(addMimeType "Ogg" "application/ogg" '(ogx) "Wikipedia: Ogg")
(addMimeType "Ogg Audio" "audio/ogg" '(oga) "Wikipedia: Ogg")
(addMimeType "Ogg Video" "video/ogg" '(ogv) "Wikipedia: Ogg")
(addMimeType "OMA Download Agents" "application/vnd.oma.dd2+xml" '(dd2) "IANA: OMA Download Agents")
(addMimeType "Open Document Text Web" "application/vnd.oasis.opendocument.text-web" '(oth) "IANA: OpenDocument Text Web")
(addMimeType "Open eBook Publication Structure" "application/oebps-package+xml" '(opf) "Wikipedia: Open eBook")
(addMimeType "Open Financial Exchange" "application/vnd.intu.qbo" '(qbo) "IANA: Open Financial Exchange")
(addMimeType "Open Office Extension" "application/vnd.openofficeorg.extension" '(oxt) "IANA: Open Office Extension")
(addMimeType "Open Score Format" "application/vnd.yamaha.openscoreformat" '(osf) "IANA: Open Score Format")
(addMimeType "Open Web Media Project - Audio" "audio/webm" '(weba) "WebM Project")
(addMimeType "Open Web Media Project - Video" "video/webm" '(webm) "WebM Project")
(addMimeType "OpenDocument Chart" "application/vnd.oasis.opendocument.chart" '(odc) "IANA: OpenDocument Chart")
(addMimeType "OpenDocument Chart Template" "application/vnd.oasis.opendocument.chart-template" '(otc) "IANA: OpenDocument Chart Template")
(addMimeType "OpenDocument Database" "application/vnd.oasis.opendocument.database" '(odb) "IANA: OpenDocument Database")
(addMimeType "OpenDocument Formula" "application/vnd.oasis.opendocument.formula" '(odf) "IANA: OpenDocument Formula")
(addMimeType "OpenDocument Formula Template" "application/vnd.oasis.opendocument.formula-template" '(odft) "IANA: OpenDocument Formula Template")
(addMimeType "OpenDocument Graphics" "application/vnd.oasis.opendocument.graphics" '(odg) "IANA: OpenDocument Graphics")
(addMimeType "OpenDocument Graphics Template" "application/vnd.oasis.opendocument.graphics-template" '(otg) "IANA: OpenDocument Graphics Template")
(addMimeType "OpenDocument Image" "application/vnd.oasis.opendocument.image" '(odi) "IANA: OpenDocument Image")
(addMimeType "OpenDocument Image Template" "application/vnd.oasis.opendocument.image-template" '(oti) "IANA: OpenDocument Image Template")
(addMimeType "OpenDocument Presentation" "application/vnd.oasis.opendocument.presentation" '(odp) "IANA: OpenDocument Presentation")
(addMimeType "OpenDocument Presentation Template" "application/vnd.oasis.opendocument.presentation-template" '(otp) "IANA: OpenDocument Presentation Template")
(addMimeType "OpenDocument Spreadsheet" "application/vnd.oasis.opendocument.spreadsheet" '(ods) "IANA: OpenDocument Spreadsheet")
(addMimeType "OpenDocument Spreadsheet Template" "application/vnd.oasis.opendocument.spreadsheet-template" '(ots) "IANA: OpenDocument Spreadsheet Template")
(addMimeType "OpenDocument Text" "application/vnd.oasis.opendocument.text" '(odt) "IANA: OpenDocument Text")
(addMimeType "OpenDocument Text Master" "application/vnd.oasis.opendocument.text-master" '(odm) "IANA: OpenDocument Text Master")
(addMimeType "OpenDocument Text Template" "application/vnd.oasis.opendocument.text-template" '(ott) "IANA: OpenDocument Text Template")
(addMimeType "OpenGL Textures (KTX)" "image/ktx" '(ktx) "KTX File Format")
(addMimeType "OpenOffice - Calc (Spreadsheet)" "application/vnd.sun.xml.calc" '(sxc) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Calc Template (Spreadsheet)" "application/vnd.sun.xml.calc.template" '(stc) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Draw (Graphics)" "application/vnd.sun.xml.draw" '(sxd) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Draw Template (Graphics)" "application/vnd.sun.xml.draw.template" '(std) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Impress (Presentation)" "application/vnd.sun.xml.impress" '(sxi) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Impress Template (Presentation)" "application/vnd.sun.xml.impress.template" '(sti) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Math (Formula)" "application/vnd.sun.xml.math" '(sxm) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Writer (Text - HTML)" "application/vnd.sun.xml.writer" '(sxw) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Writer (Text - HTML)" "application/vnd.sun.xml.writer.global" '(sxg) "Wikipedia: OpenOffice")
(addMimeType "OpenOffice - Writer Template (Text - HTML)" "application/vnd.sun.xml.writer.template" '(stw) "Wikipedia: OpenOffice")
(addMimeType "OpenType Font File" "application/x-font-otf" '(otf) "OpenType Font File")
(addMimeType "Opus Audio" "audio/opus" '(opus) "Wikipedia: Opus Audio")
(addMimeType "OSFPVG" "application/vnd.yamaha.openscoreformat.osfpvg+xml" '(osfpvg) "IANA: OSFPVG")
(addMimeType "OSGi Deployment Package" "application/vnd.osgi.dp" '(dp) "IANA: OSGi Deployment Package")
(addMimeType "PalmOS Data" "application/vnd.palm" '(pdb) "IANA: PalmOS Data")
(addMimeType "Pascal Source File" "text/x-pascal" '(p) "Wikipedia: Pascal")
(addMimeType "PawaaFILE" "application/vnd.pawaafile" '(paw) "IANA: PawaaFILE")
(addMimeType "PCL 6 Enhanced (Formely PCL XL)" "application/vnd.hp-pclxl" '(pclxl) "IANA: HP PCL XL")
(addMimeType "Pcsel eFIF File" "application/vnd.picsel" '(efif) "IANA: Picsel eFIF File")
(addMimeType "PCX Image" "image/x-pcx" '(pcx) "Wikipedia: PCX")
(addMimeType "Photoshop Document" "image/vnd.adobe.photoshop" '(psd) "Wikipedia: Photoshop Document")
(addMimeType "PICSRules" "application/pics-rules" '(prf) "W3C PICSRules")
(addMimeType "PICT Image" "image/x-pict" '(pic) "Wikipedia: PICT")
(addMimeType "pIRCh" "application/x-chat" '(chat) "Wikipedia: pIRCh")
(addMimeType "PKCS #10 - Certification Request Standard" "application/pkcs10" '(p10) "RFC 2986")
(addMimeType "PKCS #12 - Personal Information Exchange Syntax Standard" "application/x-pkcs12" '(p12) "RFC 2986")
(addMimeType "PKCS #7 - Cryptographic Message Syntax Standard" "application/pkcs7-mime" '(p7m) "RFC 2315")
(addMimeType "PKCS #7 - Cryptographic Message Syntax Standard" "application/pkcs7-signature" '(p7s) "RFC 2315")
(addMimeType "PKCS #7 - Cryptographic Message Syntax Standard (Certificate Request Response)" "application/x-pkcs7-certreqresp" '(p7r) "RFC 2986")
(addMimeType "PKCS #7 - Cryptographic Message Syntax Standard (Certificates)" "application/x-pkcs7-certificates" '(p7b) "RFC 2986")
(addMimeType "PKCS #8 - Private-Key Information Syntax Standard" "application/pkcs8" '(p8) "RFC 5208")
(addMimeType "PocketLearn Viewers" "application/vnd.pocketlearn" '(plf) "IANA: PocketLearn Viewers")
(addMimeType "Portable Anymap Image" "image/x-portable-anymap" '(pnm) "Wikipedia: Netpbm Format")
(addMimeType "Portable Bitmap Format" "image/x-portable-bitmap" '(pbm) "Wikipedia: Netpbm Format")
(addMimeType "Portable Compiled Format" "application/x-font-pcf" '(pcf) "Wikipedia: Portable Compiled Format")
(addMimeType "Portable Font Resource" "application/font-tdpfr" '(pfr) "RFC 3073")
(addMimeType "Portable Game Notation (Chess Games)" "application/x-chess-pgn" '(pgn) "Wikipedia: Portable Game Notationb")
(addMimeType "Portable Graymap Format" "image/x-portable-graymap" '(pgm) "Wikipedia: Netpbm Format")
(addMimeType "Portable Network Graphics (PNG)" "image/png" '(png) "RFC 2083")
(addMimeType "Portable Network Graphics (PNG) (Citrix client)" "image/x-citrix-png" '(png) "RFC 2083")
(addMimeType "Portable Network Graphics (PNG) (x-token)" "image/x-png" '(png) "RFC 2083")
(addMimeType "Portable Pixmap Format" "image/x-portable-pixmap" '(ppm) "Wikipedia: Netpbm Format")
(addMimeType "Portable Symmetric Key Container" "application/pskc+xml" '(pskcxml) "RFC 6030")
(addMimeType "PosML" "application/vnd.ctc-posml" '(pml) "IANA: PosML")
(addMimeType "PostScript" "application/postscript" '(ai) "Wikipedia: PostScript")
(addMimeType "PostScript Fonts" "application/x-font-type1" '(pfa) "Wikipedia: PostScript Fonts")
(addMimeType "PowerBuilder" "application/vnd.powerbuilder6" '(pbd) "IANA: PowerBuilder")
(addMimeType "Pretty Good Privacy" "application/pgp-encrypted" '(pgp) "RFC 2015")
(addMimeType "Pretty Good Privacy - Signature" "application/pgp-signature" '(pgp) "RFC 2015")
(addMimeType "Preview Systems ZipLock/VBox" "application/vnd.previewsystems.box" '(box) "IANA: Preview Systems ZipLock/Vbox")
(addMimeType "Princeton Video Image" "application/vnd.pvi.ptid1" '(ptid) "IANA: Princeton Video Image")
(addMimeType "Pronunciation Lexicon Specification" "application/pls+xml" '(pls) "RFC 4267")
(addMimeType "Proprietary P&G Standard Reporting System" "application/vnd.pg.format" '(str) "IANA: Proprietary P&G Standard Reporting System")
(addMimeType "Proprietary P&G Standard Reporting System" "application/vnd.pg.osasli" '(ei6) "IANA: Proprietary P&G Standard Reporting System")
(addMimeType "PRS Lines Tag" "text/prs.lines.tag" '(dsc) "IANA: PRS Lines Tag")
(addMimeType "PSF Fonts" "application/x-font-linux-psf" '(psf) "PSF Fonts")
(addMimeType "PubliShare Objects" "application/vnd.publishare-delta-tree" '(qps) "IANA: PubliShare Objects")
(addMimeType "Qualcomm's Plaza Mobile Internet" "application/vnd.pmi.widget" '(wg) "IANA: Qualcomm's Plaza Mobile Internet")
(addMimeType "QuarkXpress" "application/vnd.quark.quarkxpress" '(qxd) "IANA: QuarkXPress")
(addMimeType "QUASS Stream Player" "application/vnd.epson.esf" '(esf) "IANA: QUASS Stream Player")
(addMimeType "QUASS Stream Player" "application/vnd.epson.msf" '(msf) "IANA: QUASS Stream Player")
(addMimeType "QUASS Stream Player" "application/vnd.epson.ssf" '(ssf) "IANA: QUASS Stream Player")
(addMimeType "QuickAnime Player" "application/vnd.epson.quickanime" '(qam) "IANA: QuickAnime Player")
(addMimeType "Quicken" "application/vnd.intu.qfx" '(qfx) "IANA: Quicken")
(addMimeType "Quicktime Video" "video/quicktime" '(qt) "Wikipedia: Quicktime")
(addMimeType "RAR Archive" "application/x-rar-compressed" '(rar) "Wikipedia: RAR")
(addMimeType "Real Audio Sound" "audio/x-pn-realaudio" '(ram) "Wikipedia: RealPlayer")
(addMimeType "Real Audio Sound" "audio/x-pn-realaudio-plugin" '(rmp) "Wikipedia: RealPlayer")
(addMimeType "Really Simple Discovery" "application/rsd+xml" '(rsd) "Wikipedia: Really Simple Discovery")
(addMimeType "RealMedia" "application/vnd.rn-realmedia" '(rm) "")
(addMimeType "RealVNC" "application/vnd.realvnc.bed" '(bed) "IANA: RealVNC")
(addMimeType "Recordare Applications" "application/vnd.recordare.musicxml" '(mxl) "IANA: Recordare Apps")
(addMimeType "Recordare Applications" "application/vnd.recordare.musicxml+xml" '(musicxml) "IANA: Recordare Apps")
(addMimeType "Relax NG Compact Syntax" "application/relax-ng-compact-syntax" '(rnc) "Relax NG")
(addMimeType "RemoteDocs R-Viewer" "application/vnd.data-vision.rdz" '(rdz) "IANA: Data-Vision")
(addMimeType "Resource Description Framework" "application/rdf+xml" '(rdf) "RFC 3870")
(addMimeType "RetroPlatform Player" "application/vnd.cloanto.rp9" '(rp9) "IANA: RetroPlatform Player")
(addMimeType "RhymBox" "application/vnd.jisp" '(jisp) "IANA: RhymBox")
(addMimeType "Rich Text Format" "application/rtf" '(rtf) "Wikipedia: Rich Text Format")
(addMimeType "Rich Text Format (RTF)" "text/richtext" '(rtx) "Wikipedia: Rich Text Format")
(addMimeType "ROUTE 66 Location Based Services" "application/vnd.route66.link66+xml" '(link66) "IANA: ROUTE 66")
(addMimeType "RSS - Really Simple Syndication" "application/rss+xml" '(rss xml) "Wikipedia: RSS")
(addMimeType "S Hexdump Format" "application/shf+xml" '(shf) "RFC 4194")
(addMimeType "SailingTracker" "application/vnd.sailingtracker.track" '(st) "IANA: SailingTracker")
(addMimeType "Scalable Vector Graphics (SVG)" "image/svg+xml" '(svg) "Wikipedia: SVG")
(addMimeType "ScheduleUs" "application/vnd.sus-calendar" '(sus) "IANA: ScheduleUs")
(addMimeType "Search/Retrieve via URL Response Format" "application/sru+xml" '(sru) "RFC 6207")
(addMimeType "Secure Electronic Transaction - Payment" "application/set-payment-initiation" '(setpay) "IANA: SET Payment")
(addMimeType "Secure Electronic Transaction - Registration" "application/set-registration-initiation" '(setreg) "IANA: SET Registration")
(addMimeType "Secured eMail" "application/vnd.sema" '(sema) "IANA: Secured eMail")
(addMimeType "Secured eMail" "application/vnd.semd" '(semd) "IANA: Secured eMail")
(addMimeType "Secured eMail" "application/vnd.semf" '(semf) "IANA: Secured eMail")
(addMimeType "SeeMail" "application/vnd.seemail" '(see) "IANA: SeeMail")
(addMimeType "Server Normal Format" "application/x-font-snf" '(snf) "Wikipedia: Server Normal Format")
(addMimeType "Server-Based Certificate Validation Protocol - Validation Policies - Request" "application/scvp-vp-request" '(spq) "RFC 5055")
(addMimeType "Server-Based Certificate Validation Protocol - Validation Policies - Response" "application/scvp-vp-response" '(spp) "RFC 5055")
(addMimeType "Server-Based Certificate Validation Protocol - Validation Request" "application/scvp-cv-request" '(scq) "RFC 5055")
(addMimeType "Server-Based Certificate Validation Protocol - Validation Response" "application/scvp-cv-response" '(scs) "RFC 5055")
(addMimeType "Session Description Protocol" "application/sdp" '(sdp) "RFC 2327")
(addMimeType "Setext" "text/x-setext" '(etx) "Wikipedia: Setext")
(addMimeType "SGI Movie" "video/x-sgi-movie" '(movie) "SGI Facts")
(addMimeType "Shana Informed Filler" "application/vnd.shana.informed.formdata" '(ifm) "IANA: Shana Informed Filler")
(addMimeType "Shana Informed Filler" "application/vnd.shana.informed.formtemplate" '(itp) "IANA: Shana Informed Filler")
(addMimeType "Shana Informed Filler" "application/vnd.shana.informed.interchange" '(iif) "IANA: Shana Informed Filler")
(addMimeType "Shana Informed Filler" "application/vnd.shana.informed.package" '(ipk) "IANA: Shana Informed Filler")
(addMimeType "Sharing Transaction Fraud Data" "application/thraud+xml" '(tfi) "RFC 5941")
(addMimeType "Shell Archive" "application/x-shar" '(shar) "Wikipedia: Shell Archie")
(addMimeType "Silicon Graphics RGB Bitmap" "image/x-rgb" '(rgb) "RGB Image Format")
(addMimeType "SimpleAnimeLite Player" "application/vnd.epson.salt" '(slt) "IANA: SimpleAnimeLite Player")
(addMimeType "Simply Accounting" "application/vnd.accpac.simply.aso" '(aso) "IANA: Simply Accounting")
(addMimeType "Simply Accounting - Data Import" "application/vnd.accpac.simply.imp" '(imp) "IANA: Simply Accounting")
(addMimeType "SimTech MindMapper" "application/vnd.simtech-mindmapper" '(twd) "IANA: SimTech MindMapper")
(addMimeType "Sixth Floor Media - CommonSpace" "application/vnd.commonspace" '(csp) "IANA: CommonSpace")
(addMimeType "SMAF Audio" "application/vnd.yamaha.smaf-audio" '(saf) "IANA: SMAF Audio")
(addMimeType "SMAF File" "application/vnd.smaf" '(mmf) "IANA: SMAF File")
(addMimeType "SMAF Phrase" "application/vnd.yamaha.smaf-phrase" '(spf) "IANA: SMAF Phrase")
(addMimeType "SMART Technologies Apps" "application/vnd.smart.teacher" '(teacher) "IANA: SMART Technologies Apps")
(addMimeType "SourceView Document" "application/vnd.svd" '(svd) "IANA: SourceView Document")
(addMimeType "SPARQL - Query" "application/sparql-query" '(rq) "W3C SPARQL")
(addMimeType "SPARQL - Results" "application/sparql-results+xml" '(srx) "W3C SPARQL")
(addMimeType "Speech Recognition Grammar Specification" "application/srgs" '(gram) "W3C Speech Grammar")
(addMimeType "Speech Recognition Grammar Specification - XML" "application/srgs+xml" '(grxml) "W3C Speech Grammar")
(addMimeType "Speech Synthesis Markup Language" "application/ssml+xml" '(ssml) "W3C Speech Synthesis")
(addMimeType "SSEYO Koan Play File" "application/vnd.koan" '(skp) "IANA: SSEYO Koan Play File")
(addMimeType "Standard Generalized Markup Language (SGML)" "text/sgml" '(sgml) "Wikipedia: SGML")
(addMimeType "StarOffice - Calc" "application/vnd.stardivision.calc" '(sdc) "")
(addMimeType "StarOffice - Draw" "application/vnd.stardivision.draw" '(sda) "")
(addMimeType "StarOffice - Impress" "application/vnd.stardivision.impress" '(sdd) "")
(addMimeType "StarOffice - Math" "application/vnd.stardivision.math" '(smf) "")
(addMimeType "StarOffice - Writer" "application/vnd.stardivision.writer" '(sdw) "")
(addMimeType "StarOffice - Writer (Global)" "application/vnd.stardivision.writer-global" '(sgl) "")
(addMimeType "StepMania" "application/vnd.stepmania.stepchart" '(sm) "IANA: StepMania")
(addMimeType "Stuffit Archive" "application/x-stuffit" '(sit) "Wikipedia: Stuffit")
(addMimeType "Stuffit Archive" "application/x-stuffitx" '(sitx) "Wikipedia: Stuffit")
(addMimeType "SudokuMagic" "application/vnd.solent.sdkm+xml" '(sdkm) "IANA: SudokuMagic")
(addMimeType "Sugar Linux Application Bundle" "application/vnd.olpc-sugar" '(xo) "IANA: Sugar Linux App Bundle")
(addMimeType "Sun Audio - Au file format" "audio/basic" '(au) "Wikipedia: Sun audio")
(addMimeType "SundaHus WQ" "application/vnd.wqd" '(wqd) "IANA: SundaHus WQ")
(addMimeType "Symbian Install Package" "application/vnd.symbian.install" '(sis) "IANA: Symbian Install")
(addMimeType "Synchronized Multimedia Integration Language" "application/smil+xml" '(smi) "RFC 4536")
(addMimeType "SyncML" "application/vnd.syncml+xml" '(xsm) "IANA: SyncML")
(addMimeType "SyncML - Device Management" "application/vnd.syncml.dm+wbxml" '(bdm) "IANA: SyncML")
(addMimeType "SyncML - Device Management" "application/vnd.syncml.dm+xml" '(xdm) "IANA: SyncML")
(addMimeType "System V Release 4 CPIO Archive" "application/x-sv4cpio" '(sv4cpio) "Wikipedia: pax")
(addMimeType "System V Release 4 CPIO Checksum Data" "application/x-sv4crc" '(sv4crc) "Wikipedia: pax")
(addMimeType "Systems Biology Markup Language" "application/sbml+xml" '(sbml) "RFC 3823")
(addMimeType "Tab Seperated Values" "text/tab-separated-values" '(tsv) "Wikipedia: TSV")
(addMimeType "Tagged Image File Format" "image/tiff" '(tiff) "Wikipedia: TIFF")
(addMimeType "Tao Intent" "application/vnd.tao.intent-module-archive" '(tao) "IANA: Tao Intent")
(addMimeType "Tar File (Tape Archive)" "application/x-tar" '(tar) "Wikipedia: Tar")
(addMimeType "Tcl Script" "application/x-tcl" '(tcl) "Wikipedia: Tcl")
(addMimeType "TeX" "application/x-tex" '(tex) "Wikipedia: TeX")
(addMimeType "TeX Font Metric" "application/x-tex-tfm" '(tfm) "Wikipedia: TeX Font Metric")
(addMimeType "Text Encoding and Interchange" "application/tei+xml" '(tei) "RFC 6129")
(addMimeType "Text File" "text/plain" '(txt) "Wikipedia: Text File")
(addMimeType "TIBCO Spotfire" "application/vnd.spotfire.dxp" '(dxp) "IANA: TIBCO Spotfire")
(addMimeType "TIBCO Spotfire" "application/vnd.spotfire.sfs" '(sfs) "IANA: TIBCO Spotfire")
(addMimeType "Time Stamped Data Envelope" "application/timestamped-data" '(tsd) "RFC 5955")
(addMimeType "TRI Systems Config" "application/vnd.trid.tpt" '(tpt) "IANA: TRI Systems")
(addMimeType "Triscape Map Explorer" "application/vnd.triscape.mxs" '(mxs) "IANA: Triscape Map Explorer")
(addMimeType "troff" "text/troff" '(t) "Wikipedia: troff")
(addMimeType "True BASIC" "application/vnd.trueapp" '(tra) "IANA: True BASIC")
(addMimeType "TrueType Font" "application/x-font-ttf" '(ttf) "Wikipedia: TrueType")
(addMimeType "Turtle (Terse RDF Triple Language)" "text/turtle" '(ttl) "Wikipedia: Turtle")
(addMimeType "UMAJIN" "application/vnd.umajin" '(umj) "IANA: UMAJIN")
(addMimeType "Unique Object Markup Language" "application/vnd.uoml+xml" '(uoml) "IANA: UOML")
(addMimeType "Unity 3d" "application/vnd.unity" '(unityweb) "IANA: Unity 3d")
(addMimeType "Universal Forms Description Language" "application/vnd.ufdl" '(ufd) "IANA: Universal Forms Description Language")
(addMimeType "URI Resolution Services" "text/uri-list" '(uri) "RFC 2483")
(addMimeType "User Interface Quartz - Theme (Symbian)" "application/vnd.uiq.theme" '(utz) "IANA: User Interface Quartz")
(addMimeType "Ustar (Uniform Standard Tape Archive)" "application/x-ustar" '(ustar) "Wikipedia: Ustar")
(addMimeType "UUEncode" "text/x-uuencode" '(uu) "Wikipedia: UUEncode")
(addMimeType "vCalendar" "text/x-vcalendar" '(vcs) "Wikipedia: vCalendar")
(addMimeType "vCard" "text/x-vcard" '(vcf) "Wikipedia: vCard")
(addMimeType "Video CD" "application/x-cdlink" '(vcd) "Wikipedia: Video CD")
(addMimeType "Viewport+" "application/vnd.vsf" '(vsf) "IANA: Viewport+")
(addMimeType "Virtual Reality Modeling Language" "model/vrml" '(wrl) "Wikipedia: VRML")
(addMimeType "VirtualCatalog" "application/vnd.vcx" '(vcx) "IANA: VirtualCatalog")
(addMimeType "Virtue MTS" "model/vnd.mts" '(mts) "IANA: MTS")
(addMimeType "Virtue VTU" "model/vnd.vtu" '(vtu) "IANA: VTU")
(addMimeType "Visionary" "application/vnd.visionary" '(vis) "IANA: Visionary")
(addMimeType "Vivo" "video/vnd.vivo" '(viv) "IANA: Vivo")
(addMimeType "Voice Browser Call Control" "application/ccxml+xml," '(ccxml) "Voice Browser Call Control: CCXML Version 1.0")
(addMimeType "VoiceXML" "application/voicexml+xml" '(vxml) "RFC 4267")
(addMimeType "WAIS Source" "application/x-wais-source" '(src) "YoLinux")
(addMimeType "WAP Binary XML (WBXML)" "application/vnd.wap.wbxml" '(wbxml) "IANA: WBXML")
(addMimeType "WAP Bitamp (WBMP)" "image/vnd.wap.wbmp" '(wbmp) "IANA: WBMP")
(addMimeType "Waveform Audio File Format (WAV)" "audio/x-wav" '(wav) "Wikipedia: WAV")
(addMimeType "Web Distributed Authoring and Versioning" "application/davmount+xml" '(davmount) "RFC 4918")
(addMimeType "Web Open Font Format" "application/x-font-woff" '(woff) "Wikipedia: Web Open Font Format")
(addMimeType "Web Services Policy" "application/wspolicy+xml" '(wspolicy) "W3C Web Services Policy")
(addMimeType "WebP Image" "image/webp" '(webp) "Wikipedia: WebP")
(addMimeType "WebTurbo" "application/vnd.webturbo" '(wtb) "IANA: WebTurbo")
(addMimeType "Widget Packaging and XML Configuration" "application/widget" '(wgt) "W3C Widget Packaging and XML Configuration")
(addMimeType "WinHelp" "application/winhlp" '(hlp) "Wikipedia: WinHelp")
(addMimeType "Wireless Markup Language (WML)" "text/vnd.wap.wml" '(wml) "Wikipedia: WML")
(addMimeType "Wireless Markup Language Script (WMLScript)" "text/vnd.wap.wmlscript" '(wmls) "Wikipedia: WMLScript")
(addMimeType "WMLScript" "application/vnd.wap.wmlscriptc" '(wmlsc) "IANA: WMLScript")
(addMimeType "Wordperfect" "application/vnd.wordperfect" '(wpd) "IANA: Wordperfect")
(addMimeType "Worldtalk" "application/vnd.wt.stf" '(stf) "IANA: Worldtalk")
(addMimeType "WSDL - Web Services Description Language" "application/wsdl+xml" '(wsdl) "W3C Web Service Description Language")
(addMimeType "X BitMap" "image/x-xbitmap" '(xbm) "Wikipedia: X BitMap")
(addMimeType "X PixMap" "image/x-xpixmap" '(xpm) "Wikipedia: X PixMap")
(addMimeType "X Window Dump" "image/x-xwindowdump" '(xwd) "Wikipedia: X Window Dump")
(addMimeType "X.509 Certificate" "application/x-x509-ca-cert" '(der) "Wikipedia: X.509")
(addMimeType "Xfig" "application/x-xfig" '(fig) "Wikipedia: Xfig")
(addMimeType "XHTML - The Extensible HyperText Markup Language" "application/xhtml+xml" '(xhtml) "W3C XHTML")
(addMimeType "XML - Extensible Markup Language" "application/xml" '(xml) "W3C XML")
(addMimeType "XML Configuration Access Protocol - XCAP Diff" "application/xcap-diff+xml" '(xdf) "Wikipedia: XCAP")
(addMimeType "XML Encryption Syntax and Processing" "application/xenc+xml" '(xenc) "W3C XML Encryption Syntax and Processing")
(addMimeType "XML Patch Framework" "application/patch-ops-error+xml" '(xer) "RFC 5261")
(addMimeType "XML Resource Lists" "application/resource-lists+xml" '(rl) "RFC 4826")
(addMimeType "XML Resource Lists" "application/rls-services+xml" '(rs) "RFC 4826")
(addMimeType "XML Resource Lists Diff" "application/resource-lists-diff+xml" '(rld) "RFC 4826")
(addMimeType "XML Transformations" "application/xslt+xml" '(xslt) "W3C XSLT")
(addMimeType "XML-Binary Optimized Packaging" "application/xop+xml" '(xop) "W3C XOP")
(addMimeType "XPInstall - Mozilla" "application/x-xpinstall" '(xpi) "Wikipedia: XPI")
(addMimeType "XSPF - XML Shareable Playlist Format" "application/xspf+xml" '(xspf) "XML Shareable Playlist Format")
(addMimeType "XUL - XML User Interface Language" "application/vnd.mozilla.xul+xml" '(xul) "IANA: XUL")
(addMimeType "XYZ File Format" "chemical/x-xyz" '(xyz) "Wikipedia: XYZ File Format")
(addMimeType "YAML Ain't Markup Language / Yet Another Markup Language" "text/yaml" '(yaml) "YAML: YAML Ain't Markup Language")
(addMimeType "YANG Data Modeling Language" "application/yang" '(yang) "Wikipedia: YANG")
(addMimeType "YIN (YANG - XML)" "application/yin+xml" '(yin) "Wikipedia: YANG")
(addMimeType "Z.U.L. Geometry" "application/vnd.zul" '(zir) "IANA: Z.U.L.")
(addMimeType "Zip Archive" "application/zip" '(zip) "Wikipedia: Zip")
(addMimeType "ZVUE Media Manager" "application/vnd.handheld-entertainment+xml" '(zmm) "IANA: ZVUE Media Manager")
(addMimeType "Zzazz Deck" "application/vnd.zzazz.deck+xml" '(zaz) "IANA: Zzazz")

View File

@@ -1,165 +0,0 @@
#lang racket/base
(require setup/dirs
net/sendurl
net/url
net/url-connect
net/dns
racket/file
racket/system
racket/string
file/unzip
)
(provide download-racket-webview-qt
racket-webview-qt-version
racket-webview-qt-directory
racket-webview-qt-is-available?
racket-webview-qt-is-downloadable?
racket-webview-qt-resolves?
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Version info of the version to download
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define rkt-qt-version-major 0)
(define rkt-qt-version-minor 1)
(define rkt-qt-version-patch 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define rkt-qt-download-version (format "~a-~a-~a"
rkt-qt-version-major
rkt-qt-version-minor
rkt-qt-version-patch
))
(define rkt-qt-download-site "git.dijkewijk.nl")
(define rkt-qt-base-path "hans/racket-webview-qt/releases/download")
(define rkt-qt-os (system-type 'os*))
(define rkt-qt-arch (system-type 'arch))
(define rkt-download-url (format "https://~a/~a/~a/~a-~a.zip"
rkt-qt-download-site
rkt-qt-base-path
rkt-qt-download-version
rkt-qt-os
rkt-qt-arch))
(define install-path (build-path (find-system-path 'addon-dir) "racket-webview-qt"))
(define version-file (build-path install-path "version.txt"))
(define ffi-path (build-path install-path (format "~a-~a" rkt-qt-os rkt-qt-arch)))
(define (download-port link)
(let ((current-https-prot (current-https-protocol)))
(current-https-protocol 'secure)
(let* ((url (string->url link))
(port-in (get-pure-port url #:redirections 10)))
(current-https-protocol current-https-prot)
port-in)))
(define (do-download port-in port-out)
(letrec ((downloader-func (λ (count next-c len)
(let ((bytes (read-bytes 16384 port-in)))
(if (eof-object? bytes)
count
(let ((read-len (bytes-length bytes)))
(when (> read-len 0)
(set! count (+ count read-len))
(when (> count next-c)
(display (format "~a..." count))
(set! next-c (+ count len)))
(write-bytes bytes port-out)
)
(downloader-func count next-c len)))))
))
(let ((count (downloader-func 0 1000000 1000000)))
(displayln (format "~a downloaded" count))
(close-input-port port-in)
(close-output-port port-out)
count)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Provided functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (racket-webview-qt-is-available?)
(if (file-exists? version-file)
(with-handlers ([exn:fail? (λ (e) #f)])
(let ((v (file->value version-file)))
(and
(= (car v) rkt-qt-version-major)
(= (cadr v) rkt-qt-version-minor)
(= (caddr v) rkt-qt-version-patch)))
)
#f))
(define (racket-webview-qt-directory)
(if (racket-webview-qt-is-available?)
(build-path install-path (format "~a-~a" rkt-qt-os rkt-qt-arch))
#f))
(define (racket-webview-qt-resolves?)
(if (eq? (dns-find-nameserver) #f)
#f
(with-handlers ([exn:fail? (λ (e) #f)])
(dns-get-address (dns-find-nameserver) rkt-qt-download-site)
#t)
)
)
(define (racket-webview-qt-version)
(if (racket-webview-qt-is-available?)
(file->value version-file)
#f))
(define (racket-webview-qt-is-downloadable?)
(with-handlers ([exn:fail? (λ (e) #f)])
(let ((in (download-port rkt-download-url)))
(let ((d (input-port? in)))
(when d
(close-input-port in))
d))))
(define (download-racket-webview-qt)
(let ((in (download-port rkt-download-url)))
(unless (input-port? in)
(error (format "Cannot get a download port for '~a'" rkt-download-url)))
(unless (directory-exists? install-path)
(make-directory* install-path))
(let* ((file (build-path install-path "archive.zip"))
(out (open-output-file file #:exists 'replace))
)
(displayln (format "Downloading racket-webview-qt (~a)..." rkt-download-url))
(do-download in out)
(displayln (format "downloaded '~a'" file))
(when (directory-exists? ffi-path)
(displayln (format "Removing existing directory '~a'" ffi-path))
(delete-directory/files ffi-path))
(displayln "Unzipping...")
(let ((cd (current-directory)))
(current-directory install-path)
(unzip file)
(current-directory cd))
(displayln "Removing zip archive")
(delete-file file)
(displayln "Writing version")
(let ((version (list rkt-qt-version-major
rkt-qt-version-minor
rkt-qt-version-patch
)))
(let ((out (open-output-file version-file #:exists 'replace)))
(write version out)
(close-output-port out)))
(displayln "Version file written; ready for FFI integration")
#t
)
)
)

View File

@@ -1,761 +0,0 @@
#lang racket/base
(require ffi/unsafe
ffi/unsafe/define
ffi/unsafe/atomic
ffi/unsafe/os-thread
ffi/unsafe/cvector
racket/async-channel
racket/runtime-path
racket/port
data/queue
json
racket/string
racket/path
"utils.rkt"
"racket-webview-downloader.rkt"
openssl/libssl
)
(provide rkt-wv
rkt-wv-win
rkt-webview-new-context
rkt-webview-create
rkt-webview-close
rkt-webview-set-ou-token
rkt-webview-set-url!
rkt-webview-set-html!
rkt-webview-run-js
rkt-webview-call-js
rkt-webview-move
rkt-webview-resize
rkt-webview-show
rkt-webview-hide
rkt-webview-show-normal
rkt-webview-maximize
rkt-webview-minimize
rkt-webview-window-state
rkt-webview-set-title!
rkt-webview-present
rkt-webview-exit
rkt-webview-valid?
rkt-webview-open-devtools
rkt-webview-choose-dir
rkt-webview-file-open
rkt-webview-file-save
rkt-webview-messagebox
rkt-webview-version
rkt-webview-set-loglevel
rkt-webview-info
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FFI Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define lib-type 'release)
;; Check if racket-webview-qt backend is available or downloadable
(define do-ffi #t)
(define reason "")
(unless (racket-webview-qt-is-available?)
(if (racket-webview-qt-resolves?)
(if (racket-webview-qt-is-downloadable?)
(begin
(set! do-ffi (download-racket-webview-qt))
(when (eq? do-ffi #f)
(set! reason "Racket Webview Qt backend could not be downloaded"))
)
(begin
(displayln "There is no version of the racket-webview Qt backend available\n")
(displayln
(format "for OS '~a', Architecture '~a'"
(system-type 'os*)
(system-type 'arch)))
(set! do-ffi #f)
(set! reason (format
"There is no version of Racket Webview Qt for os '~a', architecture '~a' available"
(system-type 'os*)
(system-type 'arch)
)
)
)
)
(begin
(displayln "Warning: Cannot resolve racket webview download site.")
(displayln "Cannot download backend libraries and programs.")
(set! do-ffi #f)
(set! reason "Racket Webview Qt backend download site could not be resolved")
)
)
)
;; Make sure we can load the FFI library, if at all possible (i.e. do-ffi equals #t)
(define os (system-type 'os*))
(define ffi-library
(cond
([eq? os 'windows] 'rktwebview.dll)
([eq? os 'linux] 'librktwebview.so)
)
)
(define os-lib-dir
(let ((dir (racket-webview-qt-directory)))
(if (eq? dir #f)
(build-path ".")
dir)))
(define (libname lib-symbol)
(build-path os-lib-dir (symbol->string lib-symbol)))
(define quiet-call #t)
(define rktwebview-prg (if (eq? os 'windows)
"rktwebview_prg.exe"
"rktwebview_prg"))
(define webengine-process (if (eq? os 'windows)
"QtWebEngineProcess.exe"
"QtWebEngineProcess"))
;;; Actual FFI integration
(define webview-lib-file (libname ffi-library))
(define webview-lib
(if (eq? do-ffi #f)
libssl
(with-handlers ([exn:fail?
(λ (exp)
(cond
([eq? os 'linux]
(error (format
(string-append "Cannot load ~a.\n"
"Make sure you installed Qt6 on your system\n"
"NB. the minimum Qt version that is supported is Qt 6.10.\n"
"This probably means you will need to install it separately from\n"
"the standard distro packages (e.g. libqt6webenginewidgets6 on\n"
"debian based systems).\n"
"\n"
"Exception:\n\n~a")
ffi-library exp)))
(else (error
(format "Cannot load ~a for os ~a\n\nException:\n\n~a"
ffi-library os exp))))
)
])
(ffi-lib webview-lib-file '("6" #f)
#:get-lib-dirs (list os-lib-dir)
;#:custodian (current-custodian)
)
)
)
)
;; Make sure we are forgiving with the function loading.
;; forgiving with the function loading.
(define (make-ffi-repl id err . ret)
(let ((warned #f)
(msg (if (eq? do-ffi #t)
(string-append
"'~a' could not be loaded from "
(format "~a" webview-lib-file))
(string-append
"'~a' could not be loaded.\n"
reason)))
)
(λ () (λ args
(if err
(error (format msg id))
(begin
(unless warned
(displayln (format msg id))
(set! warned #t))
(car ret)))))))
(define-ffi-definer define-rktwebview
webview-lib
#:default-make-fail (λ (id)
(if (eq? do-ffi #f)
(cond
((eq? id 'rkt_webview_env)
(make-ffi-repl id #f #t))
((eq? id 'rkt_webview_events_waiting)
(make-ffi-repl id #f 0))
((eq? id 'rkt_webview_init)
(make-ffi-repl id #f #t))
((eq? id 'rkt_webview_cleanup)
(make-ffi-repl id #f #t))
(else
(make-ffi-repl id #t))
)
(make-ffi-repl id #t)))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Types / Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define _rkt_loglevel_t
(_enum '(error = 1
warning = 2
info = 3
debug = 4)
)
)
(define _rkt_result_t
(_enum '(no_result_yet = -1
oke = 0
set_html_failed = 1
set_navigate_failed = 2
eval_js_failed = 3
no_devtools_on_platform = 4
no_delegate_for_context = 5
webview_missing_dependency = 6
webview_canceled = 7
webview_invalid_state = 8
webview_invalid_argument = 9
webview_unspecified = 10
webview_dispatch_failed = 11
move_failed = 12
resize_failed = 13
choose_dir_failed = 14
open_file_failed = 15
save_file_failed = 16
failed = 17
invalid_handle = 18
)
)
)
(define _rkt_window_state_t
(_enum '(invalid = -1
normal = 0
minimized = 1
maximized = 2
hidden = 3
normal_active = 16
maximized_active = 18
)
)
)
(define _rkt_data_kind
(_enum '(version = -1
event = 2
js-result = 3
metrics = 4
)
)
)
(define _rkt_messagetype_t
(_enum '(info = 1
error = 2
warning = 3
yes-no = 4
oke-cancel = 5
)
)
)
(define-cstruct _rkt_version_t
(
[api-major _int]
[api-minor _int]
[api-patch _int]
)
)
(define-cstruct _rkt_metrics_t
([shm_usage _int]
[shm_free_depth _int]
[shm_free_size _int]
[shm_item_depth _int]
[shm_item_size _int]
[shm_item_usage_factor _double]
[open_windows _int]
[function_calls _int]
[events _int]
[log_file _string*/utf-8]
)
)
(define-cstruct _rkt_evt_t
([w _int]
[evt _pointer]
))
(define-cstruct _rkt_js_result_t
([result _rkt_result_t]
[value _pointer]
))
(define-cstruct _rkt_data_t
([kind _rkt_data_kind]
[data (_union _rkt_version_t _rkt_evt_t _rkt_js_result_t _rkt_metrics_t)]
)
)
;RKTWEBVIEW_EXPORT void rkt_webview_env(const char *env_cmds[]);
(define-rktwebview rkt_webview_env
(_fun _cvector -> _void))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_init(int &argc, char **argv);
(define-rktwebview rkt_webview_init
(_fun -> _void))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_cleanup();
(define-rktwebview rkt_webview_cleanup
(_fun -> _void))
;RKTWEBVIEW_EXPORT void rkt_webview_set_loglevel(rkt_webview_loglevel_t l);
(define-rktwebview rkt_webview_set_loglevel
(_fun _rkt_loglevel_t -> _void))
;RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_info();
(define-rktwebview rkt_webview_info
(_fun -> _rkt_data_t-pointer/null))
;RKTWEBVIEW_EXPORT int rkt_webview_events_waiting();
(define-rktwebview rkt_webview_events_waiting
(_fun -> _int))
;RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_get_event();
(define-rktwebview rkt_webview_get_event
(_fun -> _rkt_data_t-pointer/null))
;RKTWEBVIEW_QT_EXPORT rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js,
; const char *optional_server_cert_pem);
(define-rktwebview rkt_webview_new_context
(_fun _string/utf-8 _bytes -> _int))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_process_events(int for_ms);
;(define-rktwebview rkt_webview_process_events
; (_fun _int -> _void))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_free_data(rkt_data_t *d);
(define-rktwebview rkt_webview_free_data
(_fun _rkt_data_t-pointer -> _void))
;RKTWEBVIEW_QT_EXPORT rkt_data_t *rkt_webview_version();
(define-rktwebview rkt_webview_version
(_fun -> _rkt_data_t-pointer))
; RKTWEBVIEW_QT_EXPORT int rkt_webview_create(rkt_wv_context_t context,
; rktwebview_t parent)
(define-rktwebview rkt_webview_create
(_fun _int _int -> _int))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_close(int wv);
(define-rktwebview rkt_webview_close
(_fun _int -> _void))
;void rkt_webview_set_ou_token(rktwebview_t wv, const char *token)
(define-rktwebview rkt_webview_set_ou_token
(_fun _int _string/utf-8 -> _void))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_set_url(int wv, const char *url);
(define-rktwebview rkt_webview_set_url
(_fun _int _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_set_html(int wv, const char *html);
(define-rktwebview rkt_webview_set_html
(_fun _int _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_run_js(int wv, const char *js);
(define-rktwebview rkt_webview_run_js
(_fun _int _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT rkt_js_result_t *rkt_webview_call_js(rktwebview_t wv, const char *js);
(define-rktwebview rkt_webview_call_js
(_fun _int _string/utf-8 -> _rkt_data_t-pointer))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_open_devtools(int wv);
(define-rktwebview rkt_webview_open_devtools
(_fun _int -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_move(rktwebview_t w, int x, int y);
(define-rktwebview rkt_webview_move
(_fun _int _int _int -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_resize(rktwebview_t w, int width, int height);
(define-rktwebview rkt_webview_resize
(_fun _int _int _int -> _rkt_result_t))
(define-syntax def-rkt-wv
(syntax-rules ()
((_ name)
(define-rktwebview name
(_fun _int -> _rkt_result_t)))))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_hide(rktwebview_t w);
(def-rkt-wv rkt_webview_hide)
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_show(rktwebview_t w);
(def-rkt-wv rkt_webview_show)
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_show_normal(rktwebview_t w);
(def-rkt-wv rkt_webview_show_normal)
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_present(rktwebview_t w);
(def-rkt-wv rkt_webview_present)
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_maximize(rktwebview_t w);
(def-rkt-wv rkt_webview_maximize)
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_minimize(rktwebview_t w);
(def-rkt-wv rkt_webview_minimize)
;RKTWEBVIEW_QT_EXPORT bool rkt_webview_valid(rktwebview_t wv);
(define-rktwebview rkt_webview_valid
(_fun _int -> _int))
;RKTWEBVIEW_QT_EXPORT window_state_t rkt_webview_window_state(rktwebview_t w);
(define-rktwebview rkt_webview_window_state
(_fun _int -> _rkt_window_state_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_set_title(rktwebview_t wv, const char *title);
(define-rktwebview rkt_webview_set_title
(_fun _int _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT rkt_js_result_t *rkt_webview_choose_dir(rktwebview_t w, const char *title, const char *base_dir);
(define-rktwebview rkt_webview_choose_dir
(_fun _int _string/utf-8 _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT rkt_js_result_t *rkt_webview_file_open(rktwebview_t w, const char *title, const char *base_dir, const char *permitted_exts);
(define-rktwebview rkt_webview_file_open
(_fun _int _string/utf-8 _string/utf-8 _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT rkt_js_result_t *rkt_webview_file_save(rktwebview_t w, const char *title, const char *base_dir, const char *permitted_exts);
(define-rktwebview rkt_webview_file_save
(_fun _int _string/utf-8 _string/utf-8 _string/utf-8 -> _rkt_result_t))
;RKTWEBVIEW_QT_EXPORT result_t rkt_webview_message_box(
; rktwebview_t w,
; const char *title,
; const char *message,
; const char *submessage,
; rkt_messagetype_t type);
(define-rktwebview rkt_webview_message_box
(_fun _int _string/utf-8 _string/utf-8 _string/utf-8 _rkt_messagetype_t -> _rkt_result_t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Initialize and start library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(define process-events 'process)
;(define (stop-event-processing)
; (set! process-events 'stop)
; (while (eq? process-events 'stop)
; (sleep 0.001)))
;(define (start-event-processing)
; (thread (λ ()
; (letrec ((f (λ ()
; (rkt_webview_process_events 1)
; (sleep 0.001)
; (if (eq? process-events 'process)
; (f)
; (begin
; (displayln "Stopping event processing")
; (set! process-events 'stopped)
; 'done)))))
; (f)))))
(define rkt_env
(when (or (eq? os 'windows) (eq? os 'linux))
(let ((env (list (string-append "QT_PLUGIN_PATH=" (path->string (build-path os-lib-dir)))
(string-append "QTWEBENGINEPROCESS_PATH=" (path->string (build-path os-lib-dir webengine-process)))
(string-append "QTWEBENGINE_RESOURCES_PATH=" (path->string (build-path os-lib-dir "resources")))
(string-append "QTWEBENGINE_LOCALES_PATH=" (path->string (build-path os-lib-dir "translations" "qtwebengine_locales")))
(string-append "RKT_WEBVIEW_PRG=" (path->string (build-path os-lib-dir rktwebview-prg))))))
(when (eq? os 'linux)
(set! env (append
env
(list
(string-append "QT_QPA_PLATFORM=" "xcb")
(string-append "LD_LIBRARY_PATH="
(string-append
(path->string (build-path os-lib-dir)) ":"
(path->string (build-path os-lib-dir "platforms"))
)))))
)
(append env (list #f)))))
;(define env_array (_array _string/utf-8 (length rkt_env)))
;(let ((i 0))
; (while (< i (length rkt_env))
; (array-set! env_array i (list-ref rkt_env i))
; (set! i (+ i 1))))
(rkt_webview_env (list->cvector rkt_env _string/utf-8))
(rkt_webview_init)
;(set! quiet-call (start-event-processing))
(define evt-cb-hash (make-hash))
(define (start-event-processing)
(thread (λ ()
(letrec ((f (λ ()
(let ((waiting (rkt_webview_events_waiting)))
;(displayln (format "Events waiting: ~a" waiting))
(while (> waiting 0)
(let* ((rkt-evt (rkt_webview_get_event)))
;(displayln rkt-evt)
(if (eq? rkt-evt #f)
(displayln (format "Unexpected: event = nullptr"))
(let ((data (rkt_data_t-data rkt-evt)))
;(displayln data)
(let ((e (union-ref data 1)))
; (displayln e)
(let ((wv (rkt_evt_t-w e)))
;(displayln wv)
(let ((evt (cast (rkt_evt_t-evt e) _pointer _string*/utf-8)))
; (displayln evt)
(rkt_webview_free_data rkt-evt)
(let ((cb (hash-ref evt-cb-hash wv #f)))
(unless (eq? cb #f)
(cb evt)))))
)
)
)
)
(set! waiting (- waiting 1))
)
)
(sleep 0.005)
(f))
))
(f)))
)
)
(define evt-processing-thread (start-event-processing))
(define (stop-event-processing)
(kill-thread evt-processing-thread))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Provided features
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-struct rkt-wv
(win evt-queue callback [valid #:mutable] [close-callback #:mutable])
#:transparent
)
(define rkt-wv-store (make-hash))
(define (rkt-process-events handle)
(if (> (queue-length (rkt-wv-evt-queue handle)) 0)
(let ((evt (dequeue! (rkt-wv-evt-queue handle))))
(if (symbol? evt)
(if (eq? evt 'quit)
(begin
(hash-remove! rkt-wv-store (rkt-wv-win handle))
'quit)
(begin
(displayln (format "Unexpected data in event queue: ~a" evt))
(rkt-process-events handle)))
(begin
((rkt-wv-callback handle) handle evt)
(rkt-process-events handle)))
)
'done)
)
(define (rkt-webview-new-context boilerplate-js server-cert)
(rkt_webview_new_context boilerplate-js server-cert))
(define (rkt-webview-create context parent evt-callback close-callback)
(let* ((evt-queue (make-queue))
(parent-win (if (eq? parent #f) 0 (rkt-wv-win parent)))
)
(let ((wv (rkt_webview_create context parent-win)))
(hash-set! evt-cb-hash wv (λ (evt) (enqueue! evt-queue evt)))
; (λ (rkt-evt)
; (let* ((e (union-ref (rkt_data_t-data rkt-evt) 1))
; (evt (cast (rkt_evt_t-evt e) _pointer _string*/utf-8)))
; (rkt_webview_free_data rkt-evt) ; Free event data ASAP
; (enqueue! evt-queue evt)
; )))))
(let ((handle (make-rkt-wv wv evt-queue evt-callback #t close-callback)))
(thread (λ ()
(sleep 0.01)
(letrec ((f (λ ()
(let ((r (rkt-process-events handle)))
(if (eq? r 'quit)
(begin
(set-rkt-wv-valid! handle #f)
(displayln "Quitting event loop")
'done)
(begin
;(displayln "Waiting for events.")
(sleep 0.01)
(f)))))))
(f))))
(hash-set! rkt-wv-store (rkt-wv-win handle) handle)
handle))))
(define (rkt-webview-close handle)
(rkt_webview_close (rkt-wv-win handle))
(enqueue! (rkt-wv-evt-queue handle) 'quit)
(hash-remove! evt-cb-hash (rkt-wv-win handle))
((rkt-wv-close-callback handle))
#t)
(define (rkt-webview-set-loglevel l)
(rkt_webview_set_loglevel l))
(define (rkt-webview-info)
(let* ((d (rkt_webview_info))
(r (union-ref (rkt_data_t-data d) 3))
)
(let ((res
(list (list 'shm-usage (rkt_metrics_t-shm_usage r))
(list 'shm-freelist (rkt_metrics_t-shm_free_depth r) (rkt_metrics_t-shm_free_size r))
(list 'shm-alloc (rkt_metrics_t-shm_item_depth r) (rkt_metrics_t-shm_item_size r) (rkt_metrics_t-shm_item_usage_factor r))
(list 'open-windows (rkt_metrics_t-open_windows r))
(list 'calls (rkt_metrics_t-function_calls r))
(list 'events (rkt_metrics_t-events r))
(list 'log-file (rkt_metrics_t-log_file r))
)))
(rkt_webview_free_data d)
res)))
(define (rkt-webview-set-ou-token handle token)
(rkt_webview_set_ou_token (rkt-wv-win handle) token)
#t)
(define (rkt-webview-set-url! wv url)
(rkt_webview_set_url (rkt-wv-win wv) url))
(define (rkt-webview-set-html! wv html)
(rkt_webview_set_html (rkt-wv-win wv) html))
(define (rkt-webview-set-title! wv title)
(rkt_webview_set_title (rkt-wv-win wv) title))
(define (rkt-webview-run-js wv js)
(rkt_webview_run_js (rkt-wv-win wv) js))
(define (rkt-webview-call-js wv js)
(let* ((d (rkt_webview_call_js (rkt-wv-win wv) js))
(r (union-ref (rkt_data_t-data d) 2))
(value (cast (rkt_js_result_t-value r) _pointer _string*/utf-8))
(result (rkt_js_result_t-result r)))
(rkt_webview_free_data d)
(list result value)))
(define (rkt-webview-resize wv w h)
(rkt_webview_resize (rkt-wv-win wv) w h))
(define (rkt-webview-move wv x y)
(rkt_webview_move (rkt-wv-win wv) x y))
(define-syntax def-rkt-wrapper-wv
(syntax-rules ()
((_ name c-name)
(define (name wv)
(c-name (rkt-wv-win wv))))))
(def-rkt-wrapper-wv rkt-webview-show rkt_webview_show)
(def-rkt-wrapper-wv rkt-webview-hide rkt_webview_hide)
(def-rkt-wrapper-wv rkt-webview-show-normal rkt_webview_show_normal)
(def-rkt-wrapper-wv rkt-webview-minimize rkt_webview_minimize)
(def-rkt-wrapper-wv rkt-webview-maximize rkt_webview_maximize)
(def-rkt-wrapper-wv rkt-webview-present rkt_webview_present)
(def-rkt-wrapper-wv rkt-webview-window-state rkt_webview_window_state)
(define (rkt-webview-open-devtools wv)
(rkt_webview_open_devtools (rkt-wv-win wv)))
(define (rkt-webview-choose-dir wv title base-dir)
(rkt_webview_choose_dir (rkt-wv-win wv) title base-dir))
; (let* ((d (rkt_webview_choose_dir (rkt-wv-win wv) title base-dir))
; (r (union-ref (rkt_data_t-data d) 2))
; (value (cast (rkt_js_result_t-value r) _pointer _string*/utf-8))
; (result (rkt_js_result_t-result r)))
; (rkt_webview_free_data d)
; (list result value)))
(define (rkt-webview-file-open wv title base-dir permitted-exts)
(rkt_webview_file_open (rkt-wv-win wv) title base-dir permitted-exts))
; (let* ((d (rkt_webview_file_open (rkt-wv-win wv) title base-dir permitted-exts))
; (r (union-ref (rkt_data_t-data d) 2))
; (value (cast (rkt_js_result_t-value r) _pointer _string*/utf-8))
; (result (rkt_js_result_t-result r)))
; (rkt_webview_free_data d)
; (list result value)))
(define (rkt-webview-file-save wv title base-dir permitted-exts)
(rkt_webview_file_save (rkt-wv-win wv) title base-dir permitted-exts))
; (let* ((d (rkt_webview_file_save (rkt-wv-win wv) title base-dir permitted-exts))
; (r (union-ref (rkt_data_t-data d) 2))
; (value (cast (rkt_js_result_t-value r) _pointer _string*/utf-8))
; (result (rkt_js_result_t-result r)))
; (rkt_webview_free_data d)
; (list result value)))
(define (rkt-webview-messagebox wv title message submessage type)
(rkt_webview_message_box (rkt-wv-win wv) title message submessage type))
(define (rkt-webview-version)
(let ((d (rkt_webview_version)))
(let ((v (union-ref (rkt_data_t-data d) 0)))
(let ((api-major (rkt_version_t-api-major v))
(api-minor (rkt_version_t-api-minor v))
(api-patch (rkt_version_t-api-patch v))
)
(rkt_webview_free_data d)
(list (list 'webview-c-api api-major api-minor api-patch))
)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Administration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (rkt-webview-valid? wv)
(if (eq? (rkt-wv-valid wv) #f)
#f
(if (= (rkt_webview_valid (rkt-wv-win wv)) 0)
#f
#t)))
(define (rkt-webview-exit)
(let ((open-windows (hash->list rkt-wv-store)))
(for-each (λ (kv)
(let ((win (car kv))
(handle (cdr kv)))
(rkt-webview-close handle)))
open-windows))
(rkt_webview_cleanup)
(stop-event-processing)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cleanup on exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set! quiet-call
(plumber-add-flush! (current-plumber)
(λ (handle)
(rkt-webview-exit))))

View File

@@ -1,11 +0,0 @@
#lang racket/base
(provide webview-major
webview-minor
webview-patch
)
(define webview-major 0)
(define webview-minor 1)
(define webview-patch 1)

File diff suppressed because it is too large Load Diff

View File

@@ -1,128 +0,0 @@
#lang racket/base
(require racket/contract
racket-sprintf
)
(provide rgba
hex->rgba
rgba->hex
rgba?
rgba-blue
rgba-red
rgba-green
rgba-alpha
rgba-blue!
rgba-red!
rgba-green!
rgba-alpha!
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-struct rgba*
([red #:mutable] [green #:mutable] [blue #:mutable] [alpha #:mutable])
#:transparent
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Support functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (between-0-255? x)
(and (integer? x)
(>= x 0)
(<= x 255)))
(define (optional-between-0-255? x)
(write x)
(newline)
(or (null? x)
(and (= (length x) 1)
(between-0-255? (car x)))))
(define (hex2->int str)
(let ((s (string-downcase str))
(sub (- (char->integer #\a) 10))
(subnum (char->integer #\0)))
(let ((ac (string-ref s 0))
(bc (string-ref s 1)))
(let ((a (- (char->integer ac) (if (char>=? ac #\a) sub subnum)))
(b (- (char->integer bc) (if (char>=? bc #\a) sub subnum))))
(+ (* a 16) b)))))
(define (hex-color? c)
(let ((re #px"[#]?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?"))
(let ((m (regexp-match re c)))
(not (eq? m #f)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; API
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (rgba? c)
(rgba*? c))
(define/contract (rgba r g b . a)
(->* (between-0-255? between-0-255? between-0-255?) (between-0-255?) rgba?)
(make-rgba* r g b (if (null? a) 255 (car a)))
)
(define/contract (hex->rgba h)
(-> hex-color? rgba?)
(let ((re #px"[#]?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?"))
(let ((m (regexp-match re h)))
(if (eq? m #f)
(error "Not a CSS hex color string")
(rgba (hex2->int (list-ref m 1))
(hex2->int (list-ref m 2))
(hex2->int (list-ref m 3))
(if (eq? (list-ref m 4) #f)
255
(hex2->int (list-ref m 4))))))))
(define/contract (rgba->hex c)
(-> rgba? string?)
(string-append
(sprintf "#%02x%02x%02x" (rgba-red c) (rgba-green c) (rgba-blue c))
(if (= (rgba-alpha c) 255)
""
(sprintf "%02x" (rgba-alpha c)))))
(define/contract (rgba-red! c r)
(-> rgba? between-0-255? rgba?)
(set-rgba*-red! c r))
(define/contract (rgba-green! c g)
(-> rgba? between-0-255? rgba?)
(set-rgba*-green! c g))
(define/contract (rgba-blue! c b)
(-> rgba? between-0-255? rgba?)
(set-rgba*-blue! c b))
(define/contract (rgba-alpha! c a)
(-> rgba? between-0-255? rgba?)
(set-rgba*-alpha! c a))
(define/contract (rgba-red c)
(-> rgba? between-0-255?)
(rgba*-red c))
(define/contract (rgba-green c)
(-> rgba? between-0-255?)
(rgba*-green c))
(define/contract (rgba-blue c)
(-> rgba? between-0-255?)
(rgba*-blue c))
(define/contract (rgba-alpha c)
(-> rgba? between-0-255?)
(rgba*-alpha c))

View File

@@ -1,45 +0,0 @@
#lang racket/base
(require racket/class
"racket-webview.rkt"
"wv-settings.rkt"
)
(provide wv-context%)
(define wv-context%
(class object%
(init-field
base-path
[file-getter (webview-standard-file-getter base-path)]
[context-js (λ () "")]
[context-css (λ () "")]
[boilerplate-js (webview-default-boilerplate-js context-js)]
[boilerplate-css (webview-default-boilerplate-css context-css)]
[ini (error "You need to provide a 'ini' file settings interface for settings, e.g. simple-ini/class")]
)
(define wv-context #f)
(define settings-obj #f)
(define/public (context)
wv-context)
(define/public (settings section)
(send settings-obj clone section)
)
(define/public (base-url)
(wv-context-base-url wv-context))
(super-new)
(begin
(set! wv-context
(webview-new-context file-getter
#:boilerplate-js boilerplate-js
#:boilerplate-css boilerplate-css))
(set! settings-obj (new wv-settings% [ini ini] [wv-context 'global]))
)
)
)

View File

@@ -1,53 +0,0 @@
#lang racket/base
(require racket/class
"wv-window.rkt"
)
(provide wv-dialog%
)
(define (default-w) 400)
(define (default-h) 400)
(define wv-dialog%
(class wv-window%
(inherit-field parent settings wv-context html-path x y width height)
(super-new)
(define/override (init-size)
(displayln "init-size")
(let ((px (get-field x parent))
(py (get-field y parent))
(pw (get-field width parent))
(ph (get-field height parent))
)
(displayln px)
(displayln py)
(displayln pw)
(displayln ph)
(let ((dw (send settings get 'width (if (eq? width #f) (default-w) width)))
(dh (send settings get 'height (if (eq? height #f) (default-h) height)))
)
(displayln dw)
(displayln dh)
(let ((xx (/ (- pw dw) 2))
(yy (/ (- ph dh) 2)))
(let ((x (inexact->exact (round (exact->inexact (+ px xx)))))
(y (inexact->exact (round (exact->inexact (+ py yy)))))
)
(displayln (format "move ~a ~a" x y))
(send this move x y)
(displayln (format "resize ~a ~a" x y))
(send this resize dw dh)
)
)
)
)
)
)
)

View File

@@ -1,93 +0,0 @@
#lang racket/base
(require racket/class
"racket-webview.rkt"
)
(provide wv-element%)
(define wv-element%
(class object%
(init-field window
element-id
)
(define wv (hash-ref (send window info) 'wv))
(define callbacks (make-hash))
(define/public (id)
element-id)
(define/public (add-event-callback! evt cb)
(hash-set! callbacks evt cb))
(define/public (remove-event-callback! evt)
(hash-remove! callbacks evt))
(define/public (event-callback-count)
(hash-count callbacks))
(define/public (dispatch-event evt data)
(let ((cb (hash-ref callbacks evt #f)))
(if (eq? cb #f)
'wv-unhandled-js-event
(begin
(cb this evt data)
'wv-handled-js-event))))
(define/public (set-innerHTML! html)
(webview-set-innerHTML! wv element-id html)
this)
(define/public (add-class! cl)
(webview-add-class! wv element-id cl))
(define/public (remove-class! cl)
(webview-remove-class! wv element-id cl))
(define/public (display . d)
(when (not (null? d))
(let ((d* (string->symbol (format "~a" (car d)))))
(webview-set-style! wv element-id 'display d*)))
(webview-get-style wv element-id 'display))
(define/public (visibility . v)
(when (not (null? v))
(let ((v* (string->symbol (format "~a" (car v)))))
(webview-set-style! wv element-id 'visibility v*)))
(webview-get-style wv element-id 'visibility))
(define/public (set-style! styles)
(webview-set-style! wv element-id styles))
(define/public (unset-style! styles)
(webview-unset-style! wv element-id styles))
(define/public (set-attr! attr-entries)
(webview-set-attr! wv element-id attr-entries))
(define/public (attr attr)
(webview-attr wv element-id attr))
(define/public (attr/number attr)
(webview-attr/number wv element-id attr))
(define/public (attr/symbol attr)
(webview-attr/symbol wv element-id attr))
(define/public (attr/boolean attr)
(webview-attr/boolean wv element-id attr))
(define/public (attr/date attr)
(webview-attr/date wv element-id attr))
(define/public (attr/time attr)
(webview-attr/time wv element-id attr))
(define/public (attr/datetime attr)
(webview-attr/datetime wv element-id attr))
(super-new)
)
)

View File

@@ -1,52 +0,0 @@
#lang racket/base
(require racket/class
"wv-element.rkt"
"racket-webview.rkt"
)
(provide wv-input/text%
wv-input/number%
wv-input/boolean%
wv-input/date%
wv-input/time%
wv-input/datetime%
wv-input/range%
wv-input/check%
wv-input/radio%
wv-input/color%)
(define-syntax mk-cl
(syntax-rules (wv-element%)
((_ cl-name setter getter)
(define cl-name
(class wv-element%
(inherit-field window
element-id)
(super-new)
(define wv (hash-ref (send window info) 'wv))
(define/public (get)
(getter wv element-id))
(define/public (set! v)
(setter wv element-id v))
)
)
)
)
)
(mk-cl wv-input/text% webview-set-value! webview-value)
(mk-cl wv-input/number% webview-set-value! webview-value/number)
(mk-cl wv-input/boolean% webview-set-value! webview-value/boolean)
(mk-cl wv-input/date% webview-set-value! webview-value/date)
(mk-cl wv-input/time% webview-set-value! webview-value/time)
(mk-cl wv-input/datetime% webview-set-value! webview-value/datetime)
(mk-cl wv-input/range% webview-set-value! webview-value/number)
(mk-cl wv-input/check% webview-set-value! webview-value/boolean)
(mk-cl wv-input/radio% webview-set-value! webview-value/boolean)
(mk-cl wv-input/color% webview-set-value! webview-value/color)

View File

@@ -1,41 +0,0 @@
#lang racket/base
(require racket/class
simple-ini/class
)
(provide wv-settings%)
(define wv-settings%
(class object%
(init-field ini
wv-context
)
(define/public (get key . default-value)
(if (null? default-value)
(send ini get wv-context key)
(send ini get wv-context key (car default-value))))
(define/public (set! key value)
(send ini set! wv-context key value))
(define/public (get/global key . default-value)
(if (null? default-value)
(send ini get 'global key)
(send ini get 'global key (car default-value))))
(define/public (set/global! key value)
(send ini set! 'global key value))
(define/public (clone context)
(new wv-settings% [ini ini] [wv-context context]))
(define/public (context)
wv-context)
(super-new)
)
)

View File

@@ -1,475 +0,0 @@
#lang racket/base
(require "racket-webview.rkt"
racket/class
simple-ini/class
"wv-element.rkt"
"wv-input.rkt"
"wv-settings.rkt"
"rgba.rkt"
net/url
net/sendurl
racket/string
)
(provide wv-window%
(all-from-out "wv-element.rkt")
(all-from-out "wv-input.rkt")
(all-from-out "rgba.rkt")
(all-from-out "wv-settings.rkt")
webview-version
root-file-not-found-handler
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Administration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define default-x (let ((dx 100))
(λ ()
(set! dx (+ dx 25))
dx)))
(define default-y (let ((dy 100))
(λ ()
(set! dy (+ dy 25))
dy)))
(define default-w (λ () 800))
(define default-h (λ () 600))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Classes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define wv-window%
(class object%
(init-field [parent #f]
[wv-context (if (eq? parent #f)
(error "wv context is mandatory")
(get-field wv-context parent))]
[html-path (error "html path is mandatory")]
[settings (send wv-context settings (string->symbol (format "~a" html-path)))]
[title "Racket Webview Window"]
[width #f]
[height #f]
[x #f]
[y #f]
)
(define wv #f)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Administration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define/public (context)
wv-context)
(define/public (win-context)
(string->symbol (format "~a" html-path)))
(define element-hash (make-weak-hash))
(define/public (info)
(let ((h (make-hash)))
(hash-set! h 'wv-context (context))
(hash-set! h 'wv wv)
(hash-set! h 'html-path html-path)
(hash-set! h 'elements element-hash)
h))
(define/public (element id . type*)
(let ((elem (hash-ref element-hash id #f))
(type (if (null? type*) #f (car type*))))
(when (eq? elem #f)
(when (eq? type #f)
(let ((js-type (webview-call-js wv
(format
(string-append
"{ let el = document.getElementById('~a');\n"
" let a = el.getAttribute('type');\n"
" if (a === null) {\n"
" return false;\n"
" } else {\n"
" return a;\n"
" }\n"
"}")
id))))
(set! type (if (eq? js-type #f)
#f
(string->symbol (string-downcase js-type))))
)
)
(let ((cl (cond
((eq? type 'text) wv-input/text%)
((eq? type 'date) wv-input/date%)
((eq? type 'time) wv-input/time%)
((eq? type 'datetime-local) wv-input/datetime%)
((eq? type 'range) wv-input/range%)
((eq? type 'number) wv-input/number%)
((eq? type 'checkbox) wv-input/check%)
((eq? type 'radio) wv-input/radio%)
((eq? type 'color) wv-input/color%)
(else wv-element%)
)))
(set! elem (new cl [window this] [element-id id]))
(hash-set! element-hash id elem))
)
elem
)
)
(define (connect! id type event callback)
(let ((elem (element id type)))
(send elem add-event-callback! event callback)
)
)
(define (disconnect! id event)
(let ((elem (hash-ref element-hash id #f)))
(unless (eq? elem #f)
(send elem remove-event-callback! event)
(when (= (send elem event-callback-count) 0)
(hash-remove! element-hash id))
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Events
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (event-handler wv evt)
(let ((event (hash-ref evt 'event 'unknown-event))
)
(displayln evt)
(cond
((eq? event 'resize)
(send this resized (hash-ref evt 'w) (hash-ref evt 'h)))
((eq? event 'move)
(send this moved (hash-ref evt 'x) (hash-ref evt 'y)))
((eq? event 'page-loaded)
(send this page-loaded (hash-ref evt 'oke)))
((or (eq? event 'show) (eq? event 'hide) (eq? event 'maximize))
(send this window-state-changed (webview-window-state wv)))
((eq? event 'can-close?)
(when (send this can-close?)
(send this close)))
((eq? event 'closed)
(send this closed))
((eq? event 'js-evt)
(let* ((je (hash-copy (hash-ref evt 'js-evt)))
(e (make-hash)))
(hash-set! e 'evt (string->symbol (hash-ref je 'evt)))
(hash-set! e 'id (string->symbol (hash-ref je 'id "nil")))
(hash-set! e 'data (hash-ref je 'js_evt (make-hash)))
(hash-set! e 'event 'js-evt)
(when (eq? (send this js-event e) 'wv-unhandled-js-event)
(displayln (format "Unhandled javascript event: ~a" e)))
))
((eq? event 'navigation-request)
(let ((type (string->symbol (hash-ref evt 'type)))
(url (string->url (hash-ref evt 'url))))
(send this navigation-request type url)))
((or (eq? event 'file-save-ok)
(eq? event 'file-open-ok)
(eq? event 'choose-dir-ok))
(let ((file (hash-ref evt 'choosen))
(dir (hash-ref evt 'dir))
(filter (webview-filter->exts (hash-ref evt 'filter))))
(send this file-dialog-done 'ok file dir filter)))
((or (eq? event 'file-save-cancel)
(eq? event 'file-open-cancel)
(eq? event 'choose-dir-cancel))
(send this file-dialog-done 'canceled #f #f #f))
((or (eq? event 'msgbox-ok)
(eq? event 'msgbox-cancel)
(eq? event 'msgbox-yes)
(eq? event 'msgbox-no))
(send this message-done event))
(else
(displayln (format "Unhandled event: ~a (~a)" event evt)))
))
)
(define/public (moved xx yy)
(set! x xx)
(set! y yy)
(send settings set! 'x x)
(send settings set! 'y y)
)
(define/public (resized w h)
(set! width w)
(set! height h)
(send settings set! 'width w)
(send settings set! 'height h)
)
(define/public (window-state-changed st)
#t
)
(define/public (page-loaded oke)
#t)
(define/public (can-close?)
#t)
(define/public (closed)
#t)
(define/public (js-event js-event)
(let* ((evt (hash-ref js-event 'evt))
(id (hash-ref js-event 'id))
(el (hash-ref element-hash id #f))
)
(if (eq? el #f)
'wv-unhandled-js-event
(send el dispatch-event evt (hash-ref js-event 'data (make-hash))))
)
)
(define/public (navigation-request type url)
(let ((u (url->string url)))
(if (string-prefix? u (send wv-context base-url))
(begin
(webview-set-url! wv url)
'internal)
(begin
(send-url u)
'external)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Commands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define/public (add-class! selector-or-id cl)
(webview-add-class! wv selector-or-id cl)
this)
(define/public (remove-class! selector-or-id cl)
(webview-remove-class! wv selector-or-id cl)
this)
(define/public (set-menu! menu)
(webview-set-menu! wv menu)
this)
(define/public (connect-menu! id callback)
(send this bind! (string->symbol (format "~a" id)) 'menu-item-choosen
(λ (el evt data)
(callback))))
(define/public (devtools)
(webview-devtools wv)
this)
(define/public (move x y)
(webview-move wv x y)
this)
(define/public (resize w h)
(webview-resize wv w h)
this)
(define/public (close)
(webview-close wv)
this)
(define/public (bind! selector events callback)
(let ((items (webview-bind! wv selector events))
(events* (if (symbol? events) (list events) events)))
(map (λ (item)
(let ((id (car item))
(type (string->symbol (string-downcase (caddr item))))
)
(for-each (λ (evt)
(connect! id type evt callback))
events*)
(hash-ref element-hash id)
))
items)
)
)
(define/public (unbind! selector events)
(let ((items (webview-unbind! wv selector events))
(events* (if (symbol? events) (list events) events))
)
(for-each (λ (item)
(let ((id (car item)))
(for-each (λ (evt)
(send this disconnect! id evt))
events*)
))
items)
items
)
)
(define/public (set-title! title)
(webview-set-title! wv title))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Files / Directories
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define __file_dialog_cc__ #f)
(define/public (file-dialog-done flag file dir filter)
(__file_dialog_cc__ (list flag file dir filter))
)
(define/public (choose-dir title base-dir)
(unless (eq? __file_dialog_cc__ #f)
(error "Cannot display more than one file/directory dialog"))
(let* ((bd (if (eq? base-dir #f) (find-system-path 'home-dir) base-dir))
(r (webview-choose-dir wv title bd)))
(if (eq? r 'oke)
(let ((r (call/cc (λ (c) (set! __file_dialog_cc__ c)))))
(if (void? r)
'showing
(begin
(set! __file_dialog_cc__ #f)
(if (eq? (car r ) 'ok)
(cadr r)
#f))))
#f)
)
)
(define/public (file-open title base-dir filters)
(unless (eq? __file_dialog_cc__ #f)
(error "Cannot display more than one file/directory dialog"))
(let* ((bd (if (eq? base-dir #f) (find-system-path 'home-dir) base-dir))
(r (webview-file-open wv title bd filters)))
(if (eq? r 'oke)
(let ((r (call/cc (λ (c) (set! __file_dialog_cc__ c)))))
(if (void? r)
'showing
(begin
(set! __file_dialog_cc__ #f)
(if (eq? (car r) 'ok)
(cdr r)
#f))
)
)
#f)
)
)
(define/public (file-save title base-dir filters)
(unless (eq? __file_dialog_cc__ #f)
(error "Cannot display more than one file/directory dialog"))
(let* ((bd (if (eq? base-dir #f) (find-system-path 'home-dir) base-dir))
(r (webview-file-save wv title bd filters)))
(if (eq? r 'oke)
(let ((r (call/cc (λ (c) (set! __file_dialog_cc__ c)))))
(if (void? r)
'showing
(begin
(set! __file_dialog_cc__ #f)
(if (eq? (car r) 'ok)
(cdr r)
#f))
)
)
#f)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Messagebox
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define __msg_box_cc__ #f)
(define/public (message-done evt)
(__msg_box_cc__ evt)
)
(define/public (message type title message #:sub [submessage ""])
(unless (eq? __msg_box_cc__ #f)
(error "Cannot display more than one message box"))
(let ((r (webview-messagebox wv type title message #:sub submessage)))
(if (eq? r 'oke)
(let ((r (call/cc (λ (c) (set! __msg_box_cc__ c)))))
(if (void? r)
'showing
(begin
(set! __msg_box_cc__ #f)
r)))
#f)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Construction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define/public (init-size)
(let ((x* (send settings get 'x (if (eq? x #f) (default-x) x)))
(y* (send settings get 'y (if (eq? y #f) (default-y) y)))
(w* (send settings get 'width (if (eq? width #f) (default-w) width)))
(h* (send settings get 'height (if (eq? height #f) (default-h) height)))
)
(send this move x* y*)
(send this resize w* h*)
)
)
(super-new)
(begin
;; Create window
(write (list wv-context html-path event-handler parent))
(newline)
(let ((wv-parent (if (eq? parent #f) #f (hash-ref (send parent info) 'wv))))
(set! wv (webview-create
(send wv-context context)
html-path
event-handler
#:parent wv-parent)))
;; Set title
(send this set-title! title)
;; Move and resize window to settings
(send this init-size)
)
)
)
(define (root-file-not-found-handler standard-file . not-found-handler)
(letrec ((handler
(λ (file base-path path)
(if (string=? file "/")
(handler standard-file base-path (build-path base-path standard-file))
(if (string=? file "/index.html")
(if (file-exists? path)
path
(handler standard-file base-path (build-path base-path standard-file)))
(if (file-exists? path)
path
(if (null? not-found-handler)
path
((car not-found-handler) file base-path path)
)
)
)
)
)
))
handler)
)