add hooks between mime parser, content handlers, and message display, sr=mscott 351610

This commit is contained in:
bienvenu%nventure.com 2006-09-27 20:39:35 +00:00
Родитель 70e96c79ed
Коммит e024302e83
6 изменённых файлов: 43 добавлений и 4 удалений

Просмотреть файл

@ -511,6 +511,14 @@ var messageHeaderSink = {
if (!this.mDummyMsgHeader)
this.mDummyMsgHeader = new nsDummyMsgHeader();
return this.mDummyMsgHeader;
},
mProperties: null,
getProperties: function()
{
if (!this.mProperties)
this.mProperties = Components.classes["@mozilla.org/hash-property-bag;1"].
createInstance(Components.interfaces.nsIWritablePropertyBag2);
return this.mProperties;
}
};

Просмотреть файл

@ -513,7 +513,15 @@ var messageHeaderSink = {
if (!this.mDummyMsgHeader)
this.mDummyMsgHeader = new nsDummyMsgHeader();
return this.mDummyMsgHeader;
}
},
mProperties: null,
getProperties: function()
{
if (!this.mProperties)
this.mProperties = Components.classes["@mozilla.org/hash-property-bag;1"].
createInstance(Components.interfaces.nsIWritablePropertyBag2);
return this.mProperties;
}
};
function EnsureSubjectValue()

Просмотреть файл

@ -782,6 +782,11 @@ NS_IMETHODIMP TokenStreamListener::GetDummyMsgHeader(nsIMsgDBHdr **aMsgDBHdr)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TokenStreamListener::GetProperties(nsIWritablePropertyBag2 * *aProperties)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void onStartRequest (in nsIRequest aRequest, in nsISupports aContext); */
NS_IMETHODIMP TokenStreamListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{

Просмотреть файл

@ -45,6 +45,7 @@ interface nsIChannel;
interface nsIMsgMailNewsUrl;
interface nsIUTF8StringEnumerator;
interface nsIMsgDBHdr;
interface nsIWritablePropertyBag2;
[scriptable, uuid(4644FB25-5255-11d3-82B8-444553540002)]
interface nsIMimeMiscStatus : nsISupports{
@ -60,7 +61,7 @@ interface nsIMimeMiscStatus : nsISupports{
// this is a simple interface which allows someone to listen to all the headers
// that are discovered by mime. We can use this when displaying a message to update
// the msg header in JS.
[scriptable, uuid(0d6ebe53-de30-4797-9a8e-5f9be68d472c)]
[scriptable, uuid(C3C4473C-FE01-4AFC-BF91-C811BAEBEF63)]
interface nsIMsgHeaderSink : nsISupports
{
// You must finish consuming the iterators before returning from processHeaders. aHeaderNames and aHeaderValues will ALWAYS have the same
@ -83,4 +84,9 @@ interface nsIMsgHeaderSink : nsISupports
void onMsgHasRemoteContent(in nsIMsgDBHdr aMsgHdr);
nsIMsgDBHdr getDummyMsgHeader();
// used as a hook for extension mime content handlers to store data that can later
// be accessed by other parts of the code, e.g., UI code.
// TODO - Should replace securityInfo
readonly attribute nsIWritablePropertyBag2 properties;
};

Просмотреть файл

@ -36,10 +36,13 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIURI;
[scriptable, uuid(641da207-c21b-45b0-9c0c-63866c4a66b2)]
[scriptable, uuid(FC6E8234-BBF3-44A1-9802-5F023A929173)]
interface nsISimpleMimeConverter : nsISupports
{
// uri of message getting displayed
attribute nsIURI uri;
AUTF8String convertToHTML(in ACString contentType,
in AUTF8String data);
};

Просмотреть файл

@ -38,6 +38,7 @@
#include "mimecth.h"
#include "mimeobj.h"
#include "mimetext.h"
#include "mimemoz2.h"
#include "mimecom.h"
#include "nsString.h"
#include "nsReadableUtils.h"
@ -114,6 +115,14 @@ EndGather(MimeObject *obj, PRBool abort_p)
if (ssobj->buffer->IsEmpty())
return 0;
mime_stream_data *msd = (mime_stream_data *) (obj->options->stream_closure);
nsIChannel *channel = msd->channel; // note the lack of ref counting...
if (channel)
{
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
ssobj->innerScriptable->SetUri(uri);
}
nsCString asHTML;
nsresult rv = ssobj->innerScriptable->ConvertToHTML(nsDependentCString(obj->content_type),
*ssobj->buffer,
@ -148,7 +157,7 @@ static void
Finalize(MimeObject *obj)
{
MimeSimpleStub *ssobj = (MimeSimpleStub *)obj;
ssobj->innerScriptable = 0;
ssobj->innerScriptable = nsnull;
delete ssobj->buffer;
}