зеркало из https://github.com/mozilla/pjs.git
add event notification when compose window is ready for input, patch by hesslow@gmail.com, r=bienvenu,sr=mscott 324574
This commit is contained in:
Родитель
fd89da071b
Коммит
a0684432c8
|
@ -285,6 +285,8 @@ var stateListener = {
|
|||
ComposeFieldsReady();
|
||||
},
|
||||
|
||||
NotifyComposeBodyReady: function() {},
|
||||
|
||||
ComposeProcessDone: function(aResult) {
|
||||
gWindowLocked = false;
|
||||
enableEditableFields();
|
||||
|
@ -1396,6 +1398,10 @@ function ComposeStartup(recycled, aParams)
|
|||
}
|
||||
}
|
||||
|
||||
var event = document.createEvent('Events');
|
||||
event.initEvent('compose-window-init', false, true);
|
||||
document.getElementById("msgcomposeWindow").dispatchEvent(event);
|
||||
|
||||
gMsgCompose.RegisterStateListener(stateListener);
|
||||
|
||||
if (recycled)
|
||||
|
|
|
@ -101,25 +101,25 @@ interface nsIMsgCompConvertible/*ToTXT*/ {
|
|||
must be true, i.e. the higher value counts. */
|
||||
};
|
||||
|
||||
[scriptable, uuid(e72c6981-992a-11d3-a449-eb15bb19bc7c)]
|
||||
[scriptable, uuid(6ce49b2a-07dc-4783-b307-9a355423163f)]
|
||||
interface nsIMsgComposeStateListener : nsISupports
|
||||
{
|
||||
/* ... */
|
||||
void NotifyComposeFieldsReady();
|
||||
void ComposeProcessDone(in nsresult aResult);
|
||||
void SaveInFolderDone(in string folderName);
|
||||
void NotifyComposeBodyReady();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
/* TODO: we should create an interface for this enum! */
|
||||
typedef enum {
|
||||
eComposeFieldsReady,
|
||||
eComposeProcessDone,
|
||||
eSaveInFolderDone
|
||||
} TStateListenerNotification;
|
||||
%}
|
||||
[scriptable, uuid(061aae23-7e0a-4818-9a15-1b5db3ceb7f4)]
|
||||
interface nsIMsgComposeNotificationType
|
||||
{
|
||||
const long ComposeFieldsReady = 0;
|
||||
const long ComposeProcessDone = 1;
|
||||
const long SaveInFolderDone = 2;
|
||||
const long ComposeBodyReady = 3;
|
||||
};
|
||||
|
||||
native TStateListenerNotification(TStateListenerNotification);
|
||||
native nsString(nsString);
|
||||
[ref] native nsStringRef(nsString);
|
||||
|
||||
|
@ -131,7 +131,7 @@ interface nsIMsgComposeRecyclingListener : nsISupports {
|
|||
};
|
||||
|
||||
|
||||
[scriptable, uuid(a56e2be5-76c2-4647-857d-ca71b129b4d6)]
|
||||
[scriptable, uuid(bd6a81fc-e18e-413c-8086-1481b67447f4)]
|
||||
interface nsIMsgCompose : nsISupports {
|
||||
|
||||
/* ... */
|
||||
|
@ -251,8 +251,10 @@ interface nsIMsgCompose : nsISupports {
|
|||
in boolean aQuoted,
|
||||
in boolean aHTMLEditor);
|
||||
|
||||
/* Tell the doc state listeners that the doc state has changed */
|
||||
[noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType, in nsresult aResult);
|
||||
/* Tell the doc state listeners that the doc state has changed
|
||||
* aNotificationType is from nsIMsgComposeNotificationType
|
||||
*/
|
||||
[noscript] void notifyStateListeners(in long aNotificationType, in nsresult aResult);
|
||||
|
||||
/* Retreive the progress object */
|
||||
readonly attribute nsIMsgProgress progress;
|
||||
|
|
|
@ -283,6 +283,8 @@ var stateListener = {
|
|||
ComposeFieldsReady();
|
||||
},
|
||||
|
||||
NotifyComposeBodyReady: function() {},
|
||||
|
||||
ComposeProcessDone: function(aResult) {
|
||||
gWindowLocked = false;
|
||||
enableEditableFields();
|
||||
|
@ -1375,6 +1377,10 @@ function ComposeStartup(recycled, aParams)
|
|||
AddAttachment(attachments.QueryElementAt(i, Components.interfaces.nsIMsgAttachment));
|
||||
}
|
||||
|
||||
var event = document.createEvent('Events');
|
||||
event.initEvent('compose-gMsgCompose-init', false, true);
|
||||
document.getElementById("msgcomposeWindow").dispatchEvent(event);
|
||||
|
||||
gMsgCompose.RegisterStateListener(stateListener);
|
||||
|
||||
if (recycled)
|
||||
|
|
|
@ -951,7 +951,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
|
|||
rv = NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
NotifyStateListeners(eComposeProcessDone,rv);
|
||||
NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1363,11 +1363,13 @@ NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, nsIDOMWindow* aConten
|
|||
PRBool quotingToFollow = PR_FALSE;
|
||||
GetQuotingToFollow("ingToFollow);
|
||||
if (quotingToFollow)
|
||||
return BuildQuotedMessageAndSignature();
|
||||
return BuildQuotedMessageAndSignature();
|
||||
else
|
||||
{
|
||||
NotifyStateListeners(eComposeFieldsReady, NS_OK);
|
||||
return BuildBodyMessageAndSignature();
|
||||
NotifyStateListeners(nsIMsgComposeNotificationType::ComposeFieldsReady, NS_OK);
|
||||
nsresult rv = BuildBodyMessageAndSignature();
|
||||
NotifyStateListeners(nsIMsgComposeNotificationType::ComposeBodyReady, NS_OK);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2426,7 +2428,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns
|
|||
#endif
|
||||
|
||||
if (mQuoteOriginal)
|
||||
compose->NotifyStateListeners(eComposeFieldsReady, NS_OK);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeFieldsReady, NS_OK);
|
||||
|
||||
#ifdef MSGCOMP_TRACE_PERFORMANCE
|
||||
composeService->TimeStamp("Addressing widget, window title and focus are now set, time to insert the body", PR_FALSE);
|
||||
|
@ -2464,6 +2466,9 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns
|
|||
else
|
||||
InsertToCompose(editor, composeHTML);
|
||||
}
|
||||
|
||||
if (mQuoteOriginal)
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeBodyReady, NS_OK);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -3034,7 +3039,7 @@ nsresult nsMsgComposeSendListener::OnSendNotPerformed(const char *aMsgID, nsresu
|
|||
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
|
||||
if (compose)
|
||||
{
|
||||
compose->NotifyStateListeners(eComposeProcessDone,aStatus);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, aStatus);
|
||||
|
||||
nsCOMPtr<nsIMsgSendListener> externalListener;
|
||||
compose->GetExternalSendListener(getter_AddRefs(externalListener));
|
||||
|
@ -3076,7 +3081,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
|||
{
|
||||
if (fieldsFCC.LowerCaseEqualsLiteral("nocopy://"))
|
||||
{
|
||||
compose->NotifyStateListeners(eComposeProcessDone, NS_OK);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, NS_OK);
|
||||
if (progress)
|
||||
{
|
||||
progress->UnregisterListener(this);
|
||||
|
@ -3088,7 +3093,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
|||
}
|
||||
else
|
||||
{
|
||||
compose->NotifyStateListeners(eComposeProcessDone, NS_OK);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, NS_OK);
|
||||
if (progress)
|
||||
{
|
||||
progress->UnregisterListener(this);
|
||||
|
@ -3109,7 +3114,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
|||
#ifdef NS_DEBUG
|
||||
printf("nsMsgComposeSendListener: the message send operation failed!\n");
|
||||
#endif
|
||||
compose->NotifyStateListeners(eComposeProcessDone,aStatus);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, aStatus);
|
||||
if (progress)
|
||||
{
|
||||
progress->CloseProgressDialog(PR_TRUE);
|
||||
|
@ -3188,7 +3193,7 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
|||
progress->CloseProgressDialog(NS_FAILED(aStatus));
|
||||
}
|
||||
|
||||
compose->NotifyStateListeners(eComposeProcessDone,aStatus);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, aStatus);
|
||||
|
||||
if (NS_SUCCEEDED(aStatus))
|
||||
{
|
||||
|
@ -3200,7 +3205,7 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
|||
if (mDeliverMode == nsIMsgSend::nsMsgSaveAsDraft ||
|
||||
mDeliverMode == nsIMsgSend::nsMsgSaveAsTemplate)
|
||||
{
|
||||
compose->NotifyStateListeners(eSaveInFolderDone,aStatus);
|
||||
compose->NotifyStateListeners(nsIMsgComposeNotificationType::SaveInFolderDone, aStatus);
|
||||
// Remove the current draft msg when saving as draft/template is done.
|
||||
compose->SetDeleteDraft(PR_TRUE);
|
||||
RemoveCurrentDraftMessage(compose, PR_TRUE);
|
||||
|
@ -3833,7 +3838,7 @@ nsMsgCompose::BuildBodyMessageAndSignature()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotificationType, nsresult aResult)
|
||||
nsresult nsMsgCompose::NotifyStateListeners(PRInt32 aNotificationType, nsresult aResult)
|
||||
{
|
||||
if (!mStateListeners)
|
||||
return NS_OK; // maybe there just aren't any.
|
||||
|
@ -3851,18 +3856,22 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
|
|||
{
|
||||
switch (aNotificationType)
|
||||
{
|
||||
case eComposeFieldsReady:
|
||||
case nsIMsgComposeNotificationType::ComposeFieldsReady:
|
||||
thisListener->NotifyComposeFieldsReady();
|
||||
break;
|
||||
|
||||
case eComposeProcessDone:
|
||||
case nsIMsgComposeNotificationType::ComposeProcessDone:
|
||||
thisListener->ComposeProcessDone(aResult);
|
||||
break;
|
||||
|
||||
case eSaveInFolderDone:
|
||||
case nsIMsgComposeNotificationType::SaveInFolderDone:
|
||||
thisListener->SaveInFolderDone(m_folderName.get());
|
||||
break;
|
||||
|
||||
case nsIMsgComposeNotificationType::ComposeBodyReady:
|
||||
thisListener->NotifyComposeBodyReady();
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown notification");
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче