Bug 1138689 - /me and /action should fire a sending-message notification before actually sending the action. r=clokep
This commit is contained in:
Родитель
c17ab6c596
Коммит
631a4702a1
1
AUTHORS
1
AUTHORS
|
@ -30,6 +30,7 @@ Anirvana Mishra <anidps@gmail.com>
|
||||||
Annie Sullivan <annie.sullivan@gmail.com>
|
Annie Sullivan <annie.sullivan@gmail.com>
|
||||||
Archaeopteryx <archaeopteryx@coole-files.de>
|
Archaeopteryx <archaeopteryx@coole-files.de>
|
||||||
ArentJan Banck <ajbanck@planet.nl>
|
ArentJan Banck <ajbanck@planet.nl>
|
||||||
|
Arlo Breault <arlolra@gmail.com>
|
||||||
Arthur Wiebe <artooro@gmail.com>
|
Arthur Wiebe <artooro@gmail.com>
|
||||||
Asaf Romano <mano@mozilla.com>
|
Asaf Romano <mano@mozilla.com>
|
||||||
Atul Varma <atul@mozilla.com>
|
Atul Varma <atul@mozilla.com>
|
||||||
|
|
|
@ -78,10 +78,12 @@ interface imIConversationsService: nsISupports {
|
||||||
// the conversation service notifies observers of `preparing-message` and
|
// the conversation service notifies observers of `preparing-message` and
|
||||||
// `sending-message` (typically add-ons) of an outgoing message, which can be
|
// `sending-message` (typically add-ons) of an outgoing message, which can be
|
||||||
// transformed or cancelled.
|
// transformed or cancelled.
|
||||||
[scriptable, uuid(4391ba5c-9566-41a9-bb9b-fd0a0a490c2c)]
|
[scriptable, uuid(f88535b1-0b99-433b-a6de-c1a4bf8b43ea)]
|
||||||
interface imIOutgoingMessage: nsISupports {
|
interface imIOutgoingMessage: nsISupports {
|
||||||
attribute AUTF8String message;
|
attribute AUTF8String message;
|
||||||
attribute boolean cancelled;
|
attribute boolean cancelled;
|
||||||
|
// Outgoing message is an action command.
|
||||||
|
readonly attribute boolean action;
|
||||||
readonly attribute prplIConversation conversation;
|
readonly attribute prplIConversation conversation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ function OutgoingMessage(aMsg, aConversation) {
|
||||||
}
|
}
|
||||||
OutgoingMessage.prototype = {
|
OutgoingMessage.prototype = {
|
||||||
__proto__: ClassInfo("imIOutgoingMessage", "Outgoing Message"),
|
__proto__: ClassInfo("imIOutgoingMessage", "Outgoing Message"),
|
||||||
cancelled: false
|
cancelled: false,
|
||||||
|
action: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function imMessage(aPrplMessage) {
|
function imMessage(aPrplMessage) {
|
||||||
|
|
|
@ -20,6 +20,16 @@ function getAccount(aConv) getConv(aConv)._account;
|
||||||
// Trim leading and trailing spaces and split a string by any type of space.
|
// Trim leading and trailing spaces and split a string by any type of space.
|
||||||
function splitInput(aString) aString.trim().split(/\s+/);
|
function splitInput(aString) aString.trim().split(/\s+/);
|
||||||
|
|
||||||
|
function OutgoingMessage(aMsg, aConversation, aAction) {
|
||||||
|
this.message = aMsg;
|
||||||
|
this.conversation = aConversation;
|
||||||
|
this.action = !!aAction;
|
||||||
|
}
|
||||||
|
OutgoingMessage.prototype = {
|
||||||
|
__proto__: ClassInfo("imIOutgoingMessage", "Outgoing Message"),
|
||||||
|
cancelled: false
|
||||||
|
};
|
||||||
|
|
||||||
// Kick a user from a channel
|
// Kick a user from a channel
|
||||||
// aMsg is <user> [comment]
|
// aMsg is <user> [comment]
|
||||||
function kickCommand(aMsg, aConv) {
|
function kickCommand(aMsg, aConv) {
|
||||||
|
@ -65,12 +75,7 @@ function messageCommand(aMsg, aConv, aReturnedConv, aIsNotice = false) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Give add-ons an opportunity to tweak or cancel the message.
|
// Give add-ons an opportunity to tweak or cancel the message.
|
||||||
let om = {
|
let om = new OutgoingMessage(message, conv);
|
||||||
__proto__: ClassInfo("imIOutgoingMessage", "Outgoing Message"),
|
|
||||||
message: message,
|
|
||||||
conversation: conv,
|
|
||||||
cancelled: false
|
|
||||||
};
|
|
||||||
conv.notifyObservers(om, "sending-message");
|
conv.notifyObservers(om, "sending-message");
|
||||||
// If a NOTICE is cancelled and resent, it will end up being sent as PRIVMSG.
|
// If a NOTICE is cancelled and resent, it will end up being sent as PRIVMSG.
|
||||||
if (om.cancelled)
|
if (om.cancelled)
|
||||||
|
@ -96,15 +101,22 @@ function actionCommand(aMsg, aConv) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let conv = getConv(aConv);
|
let conv = getConv(aConv);
|
||||||
|
|
||||||
|
// Give add-ons an opportunity to tweak or cancel the action.
|
||||||
|
let om = new OutgoingMessage(aMsg, aConv, true);
|
||||||
|
conv.notifyObservers(om, "sending-message");
|
||||||
|
if (om.cancelled)
|
||||||
|
return true;
|
||||||
|
|
||||||
let account = getAccount(aConv);
|
let account = getAccount(aConv);
|
||||||
if (!ctcpCommand(aConv, aConv.name, "ACTION", aMsg)) {
|
if (!ctcpCommand(aConv, aConv.name, "ACTION", om.message)) {
|
||||||
conv.writeMessage(account._currentServerName, _("error.sendMessageFailed"),
|
conv.writeMessage(account._currentServerName, _("error.sendMessageFailed"),
|
||||||
{error: true, system: true});
|
{error: true, system: true});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the action on our conversation.
|
// Show the action on our conversation.
|
||||||
conv.writeMessage(account._nickname, "/me " + aMsg, {outgoing: true});
|
conv.writeMessage(account._nickname, "/me " + om.message, {outgoing: true});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче