This is handled by Firefox's MIME type handling and can be configured by editing MimeTypes.rdf. I don't think there is a way to handle all but a certain type, rather it seems you have to explicitly enable your app for every MIME type you wish to handle.
Here's an example of setting the handler of .png
files to your rd program.
<RDF:Description RDF:about="urn:mimetype:image/png"
NC:fileExtensions="png"
NC:description="PNG Image"
NC:value="image/png"
NC:editable="true">
<NC:handlerProp RDF:resource="urn:mimetype:handler:image/png"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mimetype:handler:image/png"
NC:alwaysAsk="false"
NC:saveToDisk="false"
NC:useSystemDefault="false"
NC:handleInternal="false">
<NC:externalApplication RDF:resource="urn:mimetype:externalApplication:image/png"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mimetype:externalApplication:image/png"
NC:path="[PATH TO rd]"
NC:prettyName="rd" />
As for enabling the user to change the default handler to something else, this is already enabled in Firefox's preferences (Preferences->Applications).