зеркало из https://github.com/mozilla/pjs.git
partial fix for bug 10802 - new openSaveAttachment.xul & openSaveAttachment.js files to sync up with the spec
This commit is contained in:
Родитель
43a4ee64ed
Коммит
9d6808b0cd
|
@ -80,6 +80,7 @@ interface nsIMessenger : nsISupports {
|
|||
void SetDocumentCharset(in wstring characterSet);
|
||||
void saveAs(in string url, in boolean asFile, in nsIMsgIdentity identity, in nsIMsgWindow aMsgWindow);
|
||||
void openAttachment(in string url, in string displayName, in string messageUri);
|
||||
void saveAttachment(in string url, in string displayName, in string messageUri);
|
||||
void saveAllAttachments(in unsigned long count, [array, size_is(count)] in string urlArray, [array, size_is(count)] in string displayNameArray, [array, size_is(count)] in string messageUriArray);
|
||||
void find();
|
||||
void findAgain();
|
||||
|
|
|
@ -52,3 +52,5 @@ messengerdnd.js
|
|||
mailContextMenus.js
|
||||
msgPrintEngine.js
|
||||
msgPrintEngine.xul
|
||||
openSaveAttachment.xul
|
||||
openSaveAttachment.js
|
|
@ -65,6 +65,8 @@ EXPORT_RESOURCE_SAMPLES = \
|
|||
msgPrintEngine.xul \
|
||||
popTest.js \
|
||||
popTest.xul \
|
||||
openSaveAttachment.xul \
|
||||
openSaveAttachment.js \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -58,6 +58,8 @@ install::
|
|||
$(MAKE_INSTALL) mailContextMenus.js $(DIST)\bin\chrome\messenger\content
|
||||
$(MAKE_INSTALL) msgPrintEngine.js $(DIST)\bin\chrome\messenger\content
|
||||
$(MAKE_INSTALL) msgPrintEngine.xul $(DIST)\bin\chrome\messenger\content
|
||||
$(MAKE_INSTALL) openSaveAttachment.xul $(DIST)\bin\chrome\messenger\content
|
||||
$(MAKE_INSTALL) openSaveAttachment.js $(DIST)\bin\chrome\messenger\content
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\chrome\messenger\content\messenger.xul
|
||||
|
@ -92,5 +94,7 @@ clobber::
|
|||
rm -f $(DIST)\chrome\messenger\content\mailContextMenus.js
|
||||
rm -f $(DIST)\chrome\messenger\content\msgPrintEngine.js
|
||||
rm -f $(DIST)\chrome\messenger\content\msgPrintEngine.xul
|
||||
rm -f $(DIST)\chrome\messenger\content\openSaveAttachment.xul
|
||||
rm -f $(DIST)\chrome\messenger\content\openSaveAttachment.js
|
||||
|
||||
|
||||
|
|
|
@ -211,7 +211,14 @@ function AddSenderToAddressBook()
|
|||
|
||||
function OpenAttachURL(url, displayName, messageUri)
|
||||
{
|
||||
messenger.openAttachment(url, displayName, messageUri);
|
||||
var args = {dspname: displayName, opval: 0};
|
||||
|
||||
window.openDialog("chrome://messenger/content/openSaveAttachment.xul",
|
||||
"openSaveAttachment", "chrome,modal", args);
|
||||
if (args.opval == 1)
|
||||
messenger.openAttachment(url, displayName, messageUri);
|
||||
else if (args.opval == 2)
|
||||
messenger.saveAttachment(url, displayName, messageUri);
|
||||
}
|
||||
|
||||
function AddAttachmentToMenu(name, oncommand)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*/
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
var docnamebox = document.getElementById("documentNameBox");
|
||||
if (docnamebox)
|
||||
{
|
||||
var docname = window.arguments[0].dspname;
|
||||
var item = document.createElement('text');
|
||||
if (item)
|
||||
{
|
||||
docnamebox.appendChild(item);
|
||||
item.setAttribute('value', docname);
|
||||
}
|
||||
}
|
||||
var saveit = document.getElementById("saveIt");
|
||||
if (saveit)
|
||||
{
|
||||
item.setAttribute('checked', true);
|
||||
window.arguments[0].opval = 2;
|
||||
}
|
||||
doSetOKCancel(0, onCancel);
|
||||
}
|
||||
|
||||
function onOpen()
|
||||
{
|
||||
window.arguments[0].opval = 1;
|
||||
}
|
||||
|
||||
function onSave()
|
||||
{
|
||||
window.arguments[0].opval = 2;
|
||||
}
|
||||
|
||||
function onCancel()
|
||||
{
|
||||
window.arguments[0].opval = 0;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/folderPane.css" text="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/messenger.dtd">
|
||||
<window id="open-save-attachment"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
flex="100%" class="dialog" title="&openSaveAttachment.title;"
|
||||
align="vertical" onload="onLoad();" >
|
||||
|
||||
<script language="JavaScript" src="chrome://global/content/strres.js"/>
|
||||
<script src="chrome://messenger/content/openSaveAttachment.js"/>
|
||||
|
||||
<box width="360px">
|
||||
<box orient="vertical">
|
||||
<image class="question-icon"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
<box width="10px" />
|
||||
<box orient="vertical" flex="1">
|
||||
<separator class="thin"/>
|
||||
<box id="documentNameBox">
|
||||
<text value="&openSaveAttachmentHeading.label;" />
|
||||
</box>
|
||||
<separator class="thin"/>
|
||||
<html>&openSaveAttachmentWarning.label;</html>
|
||||
<separator class="thin"/>
|
||||
<text value="&openSaveAttachmentToDo.label;" />
|
||||
<separator class="thin"/>
|
||||
<radiogroup orient="vertical">
|
||||
<radio value="&openSaveAttachmentOpen.label;" oncommand="onOpen();" />
|
||||
<radio id="save_it" value="&openSaveAttachmentSave.label;" oncommand="onSave();" checked="true" />
|
||||
</radiogroup>
|
||||
<separator class="thin"/>
|
||||
</box>
|
||||
</box>
|
||||
<separator class="thin"/>
|
||||
<box id="okCancelButtons"/>
|
||||
</window>
|
|
@ -298,3 +298,11 @@ Rights Reserved.
|
|||
|
||||
<!-- Print Engine -->
|
||||
<!ENTITY printEngine.title "Printing...">
|
||||
|
||||
<!-- Open/Save Attachment -->
|
||||
<!ENTITY openSaveAttachment.title "Open/Save Attachment">
|
||||
<!ENTITY openSaveAttachmentHeading.label "Attachment: ">
|
||||
<!ENTITY openSaveAttachmentWarning.label "Some files can contain viruses or otherwise be harmful to your computer. It is important to be certain that this file is from a trustworthy source.">
|
||||
<!ENTITY openSaveAttachmentToDo.label "What would you like to do with this file?">
|
||||
<!ENTITY openSaveAttachmentOpen.label "Open it">
|
||||
<!ENTITY openSaveAttachmentSave.label "Save it to disk">
|
||||
|
|
|
@ -577,6 +577,99 @@ done:
|
|||
NS_IMETHODIMP
|
||||
nsMessenger::OpenAttachment(const char * url, const char * displayName,
|
||||
const char * messageUri)
|
||||
{
|
||||
nsIMsgMessageService * messageService = nsnull;
|
||||
nsAutoString from, to;
|
||||
nsCOMPtr<nsISupports> channelSupport;
|
||||
nsCOMPtr<nsIStreamListener> convertedListener;
|
||||
nsAutoString urlString;
|
||||
char *urlCString = nsnull;
|
||||
char *unescapedUrl = nsnull;
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
PRBool canFetchMimeParts = PR_FALSE;
|
||||
nsCAutoString fullMessageUri = messageUri;
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
NS_WITH_SERVICE(nsIStreamConverterService,
|
||||
streamConverterService,
|
||||
kIStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
if (!url) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
unescapedUrl = PL_strdup(url);
|
||||
if (!unescapedUrl) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsUnescape(unescapedUrl);
|
||||
|
||||
urlString.AssignWithConversion(unescapedUrl);
|
||||
|
||||
urlString.ReplaceSubstring(NS_ConvertASCIItoUCS2("/;section"), NS_ConvertASCIItoUCS2("?section"));
|
||||
urlCString = urlString.ToNewCString();
|
||||
|
||||
rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL));
|
||||
nsCRT::free(urlCString);
|
||||
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = GetMessageServiceFromURI(messageUri, &messageService);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
messageService->GetCanFetchMimeParts(&canFetchMimeParts);
|
||||
|
||||
if (canFetchMimeParts)
|
||||
{
|
||||
PRInt32 sectionPos = urlString.Find("?section");
|
||||
nsString mimePart;
|
||||
|
||||
urlString.Right(mimePart, urlString.Length() - sectionPos);
|
||||
fullMessageUri.AppendWithConversion(mimePart);
|
||||
|
||||
messageUri = fullMessageUri.GetBuffer();
|
||||
}
|
||||
{
|
||||
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
|
||||
aURL,
|
||||
nsnull, // inputStream
|
||||
nsnull, // contentType
|
||||
-1);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
from.AssignWithConversion(MESSAGE_RFC822);
|
||||
to.AssignWithConversion("text/xul");
|
||||
|
||||
channelSupport = do_QueryInterface(channel);
|
||||
|
||||
// *** this isn't working yet needs to come back for it
|
||||
// *** We need to use the mime stream coverter to pull out the part stream
|
||||
// *** and then pass it to the display consumer
|
||||
rv = streamConverterService->AsyncConvertData(
|
||||
from.GetUnicode(), to.GetUnicode(), nsnull,
|
||||
channelSupport, getter_AddRefs(convertedListener));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
if (canFetchMimeParts)
|
||||
rv = messageService->OpenAttachment(aURL, messageUri, convertedListener,
|
||||
mMsgWindow, nsnull,nsnull);
|
||||
else
|
||||
rv = messageService->DisplayMessage(messageUri,
|
||||
convertedListener,mMsgWindow,
|
||||
nsnull, nsnull);
|
||||
}
|
||||
|
||||
done:
|
||||
if (messageService)
|
||||
ReleaseMessageServiceFromURI(unescapedUrl, messageService);
|
||||
|
||||
PR_FREEIF(unescapedUrl);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::SaveAttachment(const char * url, const char * displayName,
|
||||
const char * messageUri)
|
||||
{
|
||||
// *** for now OpenAttachment is really a SaveAttachment
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -589,7 +682,7 @@ nsMessenger::OpenAttachment(const char * url, const char * displayName,
|
|||
if (!url) goto done;
|
||||
|
||||
#ifdef DEBUG_MESSENGER
|
||||
printf("nsMessenger::OpenAttachment(%s)\n",url);
|
||||
printf("nsMessenger::SaveAttachment(%s)\n",url);
|
||||
#endif
|
||||
unescapedUrl = PL_strdup(url);
|
||||
if (!unescapedUrl) goto done;
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "nsIPrompt.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIPop3URL.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
@ -2637,7 +2638,20 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
|
|||
nsXPIDLCString newMessageUri;
|
||||
rv = popurl->GetPop3Sink(getter_AddRefs(pop3sink));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
pop3sink->GetMessageUri(getter_Copies(newMessageUri));
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession,
|
||||
kMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
|
||||
rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
msgWindow->SelectMessage(newMessageUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче